开发者

Fetch specific field from a MySQL result array

开发者 https://www.devze.com 2022-12-13 13:42 出处:网络
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][\'medi

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[med开发者_开发知识库ia_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!


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']
0

精彩评论

暂无评论...
验证码 换一张
取 消