dongxun6690 2013-07-16 11:36
浏览 27
已采纳

使用mysql的垂直菜单不会显示数据

I am by no means an exoert I am just trying to get my head round php and mysql to create a blog for our animal rescue centre. I am trying to create a verticle menu using a 'title' and 'link' field stored in a mysql database. I came across this site whilst searching for help with another problem and have ended up on here for help on a lot of things. This is the first time I have posted though so I apologize if I have done it in the wrong place or anything. The code i have at the moment after a day and a half messing with it and reading tutorials.

<?php include 'database-connection.php' ?>
<div id="left">
<div class="left-menu">
<h3>Blog Posts</h3>
<ul>
<?php
$query = mysql_query("SELECT * FROM animalrescuediary WHERE type = 'Blog-Posts' ")
or die(mysql_error()); 
WHILE($rows = mysql_fetch_array($query));
echo "<li><a href='";
echo $rows['link'];
echo "'>";
echo $rows['title'];
echo "</a></li>";
?>
</ul>
</div><!-- left-menu -->
</div><!-- left -->

This is not chucking out any error text but it is not dispaying the menu. It's the lack of error codes that has made it hard to search for an answer. Thank you in advance for any help with this.

  • 写回答

3条回答 默认 最新

  • duandang9434 2013-07-16 11:39
    关注

    there is no statement block for your while. you cut it with the ";" at the end. try this:

    while($rows = mysql_fetch_array($query))
    {
        echo "<li><a href='";
        echo $rows['link'];
        echo "'>";
        echo $rows['title'];
        echo "</a></li>";
    }
    ?>
    </ul>
    </div><!-- left-menu -->
    </div><!-- left -->
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?