0

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!

1 Answer 1

2

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']
Sign up to request clarification or add additional context in comments.

3 Comments

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: Did you take a look at what value and structure $pages has with functions like var_dump or print_r?
@Gumbo: thanks a lot, by using var_dump i've got what i need! Yeah!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.