$conn=mysql_connect("localhost","DBtab","123456","ntab");
$sql = "SELECT * FROM 'newsclass' WHERE ybigclassid =3 ORDER BY yid DESC ";
echo $sql;
$result = mysql_query($conn,$sql);
$rowscount=mysql_num_rows($result);
if($rowscount>0)
{
while ($row = mysql_fetch_array($result)){
echo "<li><img src=".$row['ypic']." width='200' height='150' /><p><a href='#'>".$row['ytitle']."</a> </p><em>".substr($row['yaddtime'],1,8)."</em><span>".substr($row['ycontent'],1,150)."</span><b><a href='news_info.php'>更多》</a></b></li>";}
}else{echo "暂无内空";}
?>
上面的是代码,为什么总是显示暂无内容!其它不显呢,就连echo $sql;输出的也是上面的SELECT语句,请哪位大神指教!
$sql = "SELECT * FROM 'newsclass' WHERE ybigclassid =3 ORDER BY yid DESC ";
echo $sql;
$result = mysql_query($conn,$sql);
$rowscount=mysql_num_rows($result);
if($rowscount>0)
{
while ($row = mysql_fetch_array($result)){
echo "<li><img src=".$row['ypic']." width='200' height='150' /><p><a href='#'>".$row['ytitle']."</a> </p><em>".substr($row['yaddtime'],1,8)."</em><span>".substr($row['ycontent'],1,150)."</span><b><a href='news_info.php'>更多》</a></b></li>";}
}else{echo "暂无内空";}
?>
上面的是代码,为什么总是显示暂无内容!其它不显呢,就连echo $sql;输出的也是上面的SELECT语句,请哪位大神指教!
解决方案 »
- 在openssl签发证书时如何指定16字节序列号?
- 这个是什么意思的呢??
- 再次iframe问题。。高分求指点
- 继续求一个php正则,各位大侠帮帮忙
- 有相同数据的键值的数组组成一个新的数组……
- 求这种错误的解决方法:Fatal error: Call to a member function num() on a non-object in
- php图片管理
- 请问通过javascripts传递变量后的PHP文件问题.
- PHP能不能调用vb写的com组件啊?
- 如何能快速把网站的简体版转为繁体版??
- 新建了一个站点 翻译技术类文章 多提意见啊 各位
- 求大神说一下怎么把php 和mysql进行连接啊刚刚自学一点点
你没有选择数据库,查询就进行不了,自然就是 无内容 了
最后一个就是数据库呀
ntab库名;
但你的是 mysql_connect,扩展弄混了!
$sql = "SELECT * FROM 'newsclass' WHERE ybigclassid =3 ORDER BY yid DESC ";
echo $sql;
$result = mysqli_query($conn,$sql);
$rowscount=mysqli_num_rows($result);
if($rowscount>0)
{
while ($row = mysqli_fetch_array($result)){
echo "<li><img src=".$row['ypic']." width='200' height='150' /><p><a href='#'>".$row['ytitle']."</a> </p><em>".substr($row['yaddtime'],1,8)."</em><span>".substr($row['ycontent'],1,150)."</span><b><a href='news_info.php'>更多》</a></b></li>";}
}else{echo "暂无内空";}
?>
上面的是代码,为什么总是显示暂无内容!其它不显呢,就连echo $sql;输出的也是上面的SELECT语句,请哪位大神指教!
表名不能用单引号,可以用数字1前面的点,例如 `newsclass`
或者不用,例如 newsclass
$sql = "SELECT * FROM 'newsclass' WHERE ybigclassid =3 ORDER BY yid DESC ";
echo $sql; //直接echo肯定是不行的啊,都没有执行sql语句。
$result = mysql_query($conn,$sql); //
print_r($result);//这才是查看sql语句运行结果。