简体   繁体   English

while循环为空php mysql

[英]while loop is empty php mysql

    <?PHP 

require "connect.php";
$sql = "SELECT `url` FROM `laatsteberichten` ORDER BY `datum` DESC LIMIT 2";
mysql_query ($sql) or  die (mysql_error());
$result=mysql_query($sql);

while($data = mysql_fetch_row($result)){

echo("<b>$data[0]</b><br>");
}  
mysql_close($connect);
?>     

This script i'm using 4 times on my website. 这个脚本我在我的网站上使用了4次。

  • To show 10 articles from the same category at the end of every article. 在每篇文章的末尾显示同一类别的10篇文章。

To show 10 random articles at the end of every article, except the category where the article is listed in 在每篇文章的末尾显示10个随机文章,但文章中列出的类别除外

To show the 7 most viewed articles in the sidebar To show the 3 newest articles in the sidebar 在侧边栏中显示7个最受欢迎的文章在​​侧边栏中显示3个最新的文章

It works perfect for the first 3 But the last one showing only a blank bar. 它最适合前3个,但最后一个仅显示一个空白栏。 (for 3 newest articles) Source code is : <b><br></b><b><br></b><b><br></b><b><br></b><b><br></b> (针对3篇最新文章)源代码为: <b><br></b><b><br></b><b><br></b><b><br></b><b><br></b>

Can anybody help me, or let me know how I can check whats the problem? 谁能帮助我,或者让我知道如何检查问题所在?

These Code Will Be Checked 这些代码将被检查

require "connect.php";
$sql = "SELECT 'url' FROM 'laatsteberichten' ORDER BY 'datum' DESC LIMIT 2";
$result = mysql_query($sql) or  die(mysql_error());
while($data = mysql_fetch_row($result)){
echo "<b>$data['url']</b>";
}  
mysql_close($connect);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM