douxunwei7083 2009-10-26 17:50
浏览 11

MySQL和PHP显示问题?

I can't get the following code to display items from the database where the parent_id is equal to the id.

Here is the code below.

// Query member data from the database and ready it for display
$mysqli = new mysqli("localhost", "root", "", "sitename");
$dbc = mysqli_query($mysqli,"SELECT * FROM categories WHERE id=parent_id");

if (!$dbc) {
// There was an error...do something about it here...
print mysqli_error();
}

while ($row = mysqli_fetch_assoc($dbc)) {
echo '<li><a href="' , $row['url'] , '" title="' , $row['description'] , '">' , $row['category_name'] , '</a>';
   }

I think I know what I'm doing wrong how can I have this query check a previous query?

  • 写回答

3条回答 默认 最新

  • douqian1835 2009-10-26 17:53
    关注

    i think this line should be rethought:

    if ($row['parent_id'] == $row['id']) {
    

    cause are u sure its the correct logic?

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度