views:

121

answers:

1

Hi! I’m trying to retrive the field *media_file* from the first line of the query. I don’t figure how to do that. I’ve tried several times to get it by calling the multidimensional array $pages[0]['media_file'] with no success.

I’m trying to have the first image of a series bigger and then append the other thumbs. Here the page that we are talking about: http://www.svarnet.it/index.php?/works/svarnet-dream/

this is the code:

function createExhibit()
{
 $OBJ =& get_instance();
 global $rs;

 $pages = $OBJ->db->fetchArray("SELECT * 
  FROM ".PX."media, ".PX."objects_prefs 
  WHERE media_ref_id = '$rs[id]' 
  AND obj_ref_type = 'exhibit' 
  AND obj_ref_type = media_obj_type 
  ORDER BY media_order ASC, media_id ASC");

 $s = "<div id='text-container'>\n";
 $s .= $rs['content'];
 $s .= "</div>\n";
 $s .= "\n<div class='cl'><!-- --></div>\n";

 if (!$pages) return $s;


 foreach ($pages as $height)
 {
  $height = getimagesize(DIRNAME . GIMGS . "/th-$height[media_file]");

  $find_smallest_height[] = $height[1];


 }

 sort($find_smallest_height, SORT_NUMERIC);
 rsort($find_smallest_height);
 $lowest = array_pop($find_smallest_height);

 $i = 1; $a = '';



 foreach ($pages as $go)
 {
  $a .= "\n<a class='group' rel='group' href='" . BASEURL . GIMGS . "/$go[media_file]' title='$go[media_title]'><imgXXX src='" . BASEURL . GIMGS . "/th-$go[media_file]' alt='$go[media_caption]' height='80px' /></a>\n";

  $i++;
 }

 // images


 $s .= "<div id='img-container'>\n";

 // //////////////// HERE I WANT TO INSERT THE FIRST IMAGE OF THE QUERY

 $s .= "<imgXXX src='" . BASEURL . GIMGS . $pages['media_file'] . "' alt='$pages[media_title]' />";

 // THEN APPEND THE OTHERS IN THUMB FORMAT

 $s .= $a;
 $s .= "</div>\n";

 return $s;
}

Thanks in advance!

+2  A: 

You cannot access your $height['media_file'] variable inside double quoted strings like that. You will either use the complex syntax with curly braces:

"/th-{$height['media_file']}"
"/th-${height['media_file']}"

Or you use the string concatenation operator .:

"/th-".$height['media_file']
Gumbo
But the code has no errors, the only problem its that i want to get the field ['media_file'] of the first row of the query.And i dont know how to get it.$pages[0]['media_file'] isn't functioning.
iperdiscount
@iperdiscount: Did you take a look at what value and structure `$pages` has with functions like `var_dump` or `print_r`?
Gumbo
@Gumbo: thanks a lot, by using *var_dump* i've got what i need!Yeah!
iperdiscount