此代码只从表中返回一行,我无法弄清楚
<?php
$sqlrest="Select `restaurant_name` , `restaurant_id` , `menuimage` from `restaurant` where `restaurant_id` = '".mysql_real_escape_string($_REQUEST['res_id'])."'";
$result=mysql_query($sqlrest) or die(mysql_error());
while($row=mysql_fetch_array($result))
{
$c=$row['restaurant_name'];
$id=$row['restaurant_id'];
<tr>
<td><?php echo $c ; ?></td>
<td><img src="image/<?php echo $resid=get::getimage($id); ?>" width="100" height="100" /></td>
<td><a href="editrestrauntdetails.php?res_id=<?php echo $id ; ?>">Edit Restraunt Details</a></td>
<td><a href="restaurantdelete.php?res_id=<?php echo $id ; ?>" onClick="return confirmdelete();">Delete</a></td>
</tr>
<?php } ?>
正在使用的功能代码
function getimage($catid) {
$image="select * from `restimage` where `res_id`='$catid' ";
$imageresult=mysql_query($image) or die(mysql_error()) ;
while($row=mysql_fetch_assoc($imageresult)){
return $getimage=$row['rest_image'];
}
}
答案 0 :(得分:1)
如果你想要一家餐馆的所有图片。您的图像功能应返回所有图像并将其返回。 也许整个img Tag。
function getimage($catid) {
$image="select * from `restimage` where `res_id`='$catid' ";
$imageresult=mysql_query($image) or die(mysql_error()) ;
$images = array();
while($row=mysql_fetch_assoc($imageresult)){
$images[] = '<img src="image/'. $row['rest_image'] .'" width="100" height="100" />';
}
return implode('', $images);
}