views:

12

answers:

1

i am trying to get get the following working nothing is happen when i use the function i am trying to get it to display images

 class ItemRes {
//items DB
var $img="";


}
 function ShowItemImage($index,$res_a){
 if(sizeof($res_a) > $index){
 if($res_a[$index] != NULL) {
     $cimg = $res_a[$index]->img;
     return "<img src='$cimg' width='70' height='70' style='cursor:pointer'></img>";
 }
 }else{
     return "<center class='whitetxt'><strong>Empty</strong></center>";
 }
  }



 $res_array = array();
 $idx=0;
  $result21 = mysql_query("SELECT * FROM photos WHERE eid='$eid' ORDER BY id DESC") or die (mysql_error()); 
  while ($row21 = mysql_fetch_array($result21)) { 
  $img_path = $row21['path'];
  $obj = new ItemRes();
  $obj->img = $img_path;
  $res_array[$idx] = $obj;
 $idx++;
 }

 ShowItemImage(0,$res_array)
 ShowItemImage(1,$res_array)
A: 

Run a var_dump($res_array); to make sure it's populated.

Also, a little off topic, but that whole $res_array[$idx] bit is unnecessary.

To append an array just call $res_array[] = $obj;

Matt