我将如何在pagination.php中显示具有相同ID的图片? 我试过这个
<td width="20%" valign="top"><a href="product.php?id=' . $id . '">
<img style="border:#666 2px solid;" src="inventory_images/' . $id . '.jpg" width="150" height="102" border="1" /></a>
</td>
但它不会工作..使用分页显示图像的任何可能方式?
for ($i = $start; $i < $end; $i++)
{
// make sure that PHP doesn't try to show results that don't exist
if ($i == $total_results) { break; }
// echo out the contents of each row into a table
echo "<tr>";
echo '<td>' . mysql_result($result, $i, 'product_name') . '</td>';
echo '<td>' . mysql_result($result, $i, 'price') . '</td>';
echo '<td>' . mysql_result($result, $i, 'details') . '</td>';
echo '<td>' . mysql_result($result, $i, 'category') . '</td>';
echo '<td>' . mysql_result($result, $i, 'subcategory') . '</td>';
echo '<td><a href="product.php?id=' . mysql_result($result, $i, 'id') . '">Click To View</a></td>';
echo "</tr>";
}
答案 0 :(得分:0)
你可能需要输入类似的代码:
<td width="20%" valign="top">
<a href="product.php?id=<?php echo $id; ?>">
<img style="border:#666 2px solid;" src="inventory_images/<?php echo $id; ?>.jpg" width="150" height="102" border="1" />
</a>
</td>
检查生成的源并调整上面的代码。请记住,在HTML中你不能直接输入php变量。你必须用php echo语句输出它们:
<html>
SOME HTML
<div class="valueFromPhp"><?php echo $value; ?></div>
</html>
还要记住使用htmlentities()来逃避输出以防止XSS攻击。
答案 1 :(得分:-1)
echo '
<td>
<img width=100 src="../PHP/saved_images/'.mysql_result($result, $i, "bkimg").'">
</td>
';