【发布时间】:2016-10-29 20:12:43
【问题描述】:
<?php
$conn = mysql_connect("localhost","root","");
if(!$conn){
echo mysql_error();
}
$db = mysql_select_db("imagestore",$conn);
if(!$db ){
echo mysql_error();
}
$q = "SELECT * FROM imagetable";
$r = mysql_query("$q",$conn);
if($r)
{
while($row=mysql_fetch_array($r) )
{
header("Content-type: text/html");
echo "</br>";
echo $row['photoname'];
echo "</br>";
$type = "Content-type: ".$row['phototype'];
header($type);
echo "<img src=image.php?fotoid=". $row['fotoid']."width =300 height = 35. 300/>";
}
}
else{
echo mysql_error();
}
?>
【问题讨论】:
-
您要查找的 SQL 子句是
ORDER BY。当您从数据库中选择记录时,使用它对记录进行排序。 -
为什么你的问题总结了你的代码? (行号..),你能用right formatting吗?