Вопрос

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>
    '
    }
    ?>
Это было полезно?

Решение

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.

//Get information from db.
<?php
    $query = tep_db_query("SELECT tabid, tabtitle, tabcontent FROM table1");
    while ($row = mysql_fetch_assoc($query)) {
        $table[] = $row;
    }
?>

<ul>
<?php foreach($table as $row){
    echo '<li><a href="#tabs-' . $row['tabid'] . '">' . $row['tabtitle'] . '</a></li>';
}
?>
</ul>

<?php foreach($table as $row){
    echo '
    <div id="tabs-' . $row['tabid'] . '">

    <p> ' . $row['tabcontent'] . ' </p>
    ';
}
?>
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top