使用 SQL 填充导航选项卡?
我正在寻找某种允许由 SQL 填充的导航选项卡(垂直)。例如,在 SQL 表中会有一个标题列(即选项卡的标题)和一个选项卡内容列。
我尝试过自己构建一个,但我不知道如何将其放入导航栏中,因为通常我会做一个 while 循环来用 SQL 填充某些内容,但因为导航有两件事需要填充(< ;li>
和
位),我不确定该怎么做。谢谢。
编辑:
<ul>
<?php
$query = tep_db_query("select * table1");
while ($row = mysql_fetch_assoc($query)) {
echo '<li><a href="#tabs-' . $row['tabid'] . '">' . $row['tabtitle'] . '</a></li>'
}
?>
</ul>
<?php
$query2 = tep_db_query("select * table1");
while ($row = mysql_fetch_assoc($query2)) {
echo '
<div id="tabs-' . $row['tabid'] . '">
<p> ' . $row['tabcontent'] . ' </p>
'
}
?>
I'm looking for some kind of Nav tab (vertical) that allows it to be populated by SQL. For example, in the SQL table there would be a column for title (which is the title of the tab) and a column for the contents of the tab.
I have tried building one myself, but I have no idea how to fit it in a nav bar because usually I'd do a while loop to populate something with SQL, but because nav's have two things that need populating (the <li>
and the <div>
bits), I am unsure of how to do it.
Thanks.
Edit:
<ul>
<?php
$query = tep_db_query("select * table1");
while ($row = mysql_fetch_assoc($query)) {
echo '<li><a href="#tabs-' . $row['tabid'] . '">' . $row['tabtitle'] . '</a></li>'
}
?>
</ul>
<?php
$query2 = tep_db_query("select * table1");
while ($row = mysql_fetch_assoc($query2)) {
echo '
<div id="tabs-' . $row['tabid'] . '">
<p> ' . $row['tabcontent'] . ' </p>
'
}
?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你所拥有的似乎没问题,你也许可以做这样的事情来消除一半的数据库调用。
What you have seems like it would be okay, you might be able to do something like this in order to eliminate half of your db calls.