SQL查询未显示第一个结果? [英] SQL query not displaying the first result?

查看:88
本文介绍了SQL查询未显示第一个结果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在我的php页面中动态创建一个导航菜单.

I am trying to dynamically create a navigation menu in my php page.

我有一个查询来创建活动页面列表,但是由于某种原因,第一个结果从不显示

I have a query to create a list of the active pages but for some reason the first result never shows

$menu = mysql_query("SELECT link FROM myTable WHERE active_page='y' ORDER BY menu_order");
$menulist = mysql_fetch_array($menu);

  while($menulist = mysql_fetch_array($menu))
  {
  $themenu = $themenu . "<li><a href='#'>" . $menulist['link'] . "</a></li>";
  }

  $echo $themenu;

返回

项目2
项目3
项目4
...

item 2
item 3
item 4
...

任何可能的原因

推荐答案

删除

$menulist = mysql_fetch_array($menu);

此无关紧要的调用正在提取第一条记录,但是您没有使用它,因为您在where循环中.

This extraneous call is pulling the first record, but you're not doing anything with it as you are in your where loop.

这篇关于SQL查询未显示第一个结果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆