【问题标题】:i created a table in database to display photos and i made it to display ,but i want them to display from the last to the first我在数据库中创建了一个表格来显示照片并让它显示,但我希望它们从最后一个显示到第一个
【发布时间】: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吗?

标签: mysql sorting


【解决方案1】:

我知道ORDER,但无法在我的页面中显示我想要的照片。 我是初学者。 我用$q = "SELECT * FROM imagetable ORDER BY fotoid DESC";

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-10-07
    • 2018-05-07
    • 1970-01-01
    • 2014-03-21
    • 2022-11-26
    • 2022-11-11
    • 1970-01-01
    相关资源
    最近更新 更多