为了账号安全,请及时绑定邮箱和手机立即绑定

取不出数据库的文章内容

为什么我写的管理页面取不出数据库的文章

<?php

require_once('../connect.php');

$sql = "select * from article order by dateline desc";

$query  = mysql_query($sql);

if($query&&mysql_num_rows($query)){

while($row =mysql_fetch_assoc($query)){

$data[] = $row;

}

}else{

$data = array();

}


?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>无标题文档</title>

<style type="text/css">

body {

margin-left: 0px;

margin-top: 0px;

margin-right: 0px;

margin-bottom: 0px;

}

</style>

</head>


<body>

<table width="100%" height="520" border="0" cellpadding="8" cellspacing="1" bgcolor="#000000">

  <tr>

    <td height="89" colspan="2" bgcolor="#FFFF99"><strong>后台管理系统</strong></td>

  </tr>

  <tr>

    <td width="156" height="287" align="left" valign="top" bgcolor="#FFFF99"><p><a href="article.add.php">发布文章</a></p>

    <p><a href="article.manage.php">管理文章</a></p></td>

    <td width="837" valign="top" bgcolor="#FFFFFF"><table width="743" border="0" cellpadding="8" cellspacing="1" bgcolor="#000000">

      <tr>

        <td colspan="3" align="center" bgcolor="#FFFFFF">文章管理列表</td>

        </tr>

      <tr>

        <td width="37" bgcolor="#FFFFFF">编号</td>

        <td width="572" bgcolor="#FFFFFF">标题</td>

        <td width="82" bgcolor="#FFFFFF">操作</td>

      </tr>

<?php 

if(!empty($data)){

foreach($data as $value){

?>

      <tr>

        <td bgcolor="#FFFFFF">&nbsp;<?php echo $value['id']?></td>

        <td bgcolor="#FFFFFF">&nbsp;<?php echo $value['title']?></td>

        <td bgcolor="#FFFFFF"><a href="article.del.handle.php?id=<?php echo $value['id']?>">删除</a> <a href="article.modify.php?id=<?php echo $value['id']?>">修改</a></td>

      </tr>

        <?php

        }

}

        ?>

    </table></td>

  </tr>

  <tr>

    <td colspan="2" bgcolor="#FFFF99"><strong>版权所有</strong></td>

  </tr>

</table>

</body>

</html>


正在回答

2 回答

额,php的最后一条语句可以不用分号,你可以试一下在while循环里输出$row,看一下是否有数据输出;

0 回复 有任何疑惑可以回复我~

1、foreach循环里面的php语句没有以分号结尾;

2、数据库里面是否有数据?

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
PHP与MySQL关系大揭秘
  • 参与学习       72509    人
  • 解答问题       978    个

让我们一起走上探秘之旅,找寻php和mysql恋爱的真谛

进入课程

取不出数据库的文章内容

我要回答 关注问题
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号