我对这一切还是陌生的,似乎找不到这个问题。这是每个人都看到的我的主页。
<?php
// Connects to your Database
mysql_connect("localhost", "....", "....") or die(mysql_error());
mysql_select_db("....") or die(mysql_error());
//print animals
$result = @mysql_query("SELECT * FROM animals ORDER BY id ASC LIMIT 10;");
while($row=@mysql_fetch_array($result)){
?>
<center><font size=3><font color=#eeb58c><?phpecho $row["Animal Description"]; ?><center>
<center><font size=1><font color=#eeb58c><?php echo $row["Animal Id"]; ?><center>
<center><?php
$qry = "select ID from animals";
$res = mysql_query($qry) or die(mysql_error());
while($row = mysql_fetch_array($res)) { echo "<img src=inc/image.php?id='$row[0]'>"; }}
?><center>
<?php
//close database connection
@mysql_close();
?>
这是 image.php 页面
<?php
// Connects to your Database
mysql_connect("localhost", "test", "test") or die(mysql_error());
mysql_select_db("dogs") or die(mysql_error());
$result = mysql_query("SELECT Photo FROM animals WHERE ID= ".$_GET['id']);
if($result === FALSE)
die(mysql_error()); // TODO: better error handling
$row = mysql_fetch_array($result);
header("Content-type: image/jpeg", true);
echo $row['Photo'];
?>
这是我查看源代码时看到的
<center><font size=3><font color=#eeb58c><?phpecho $row["Animal Description"]; ?><center>
<center><font size=1><font color=#eeb58c>test<center>
<center><img src=inc/image.php?id='2'><img src=inc/image.php?id='3'><center><font size=3><font color=#eeb58c><?phpecho $row["Animal Description"]; ?><center>
<center><font size=1><font color=#eeb58c>test 2<center>
<center><img src=inc/image.php?id='2'><img src=inc/image.php?id='3'><center>
正如您在源代码中看到的,显示图像 id 2 和 3 我需要它做的是测试显示图像 id 2 和测试 2 显示 id 3 等等。任何帮助将不胜感激。