0

I'm trying to input my mysql database into this html table without messing up the css, I've tried to do it as shown here with a table, but I can't get it to work.

http://www.w3schools.com/php/php_mysql_select.asp

The list should look like so..

Categories

Business
Computer Science
Economics
English
Engineering
Mathematics
Statistics
Student Success

Here is my code,

 <div class="col-md-2">  <!-- start left navigation rail column -->
         <div class="panel panel-info spaceabove">
            <div class="panel-heading"><h4>Categories</h4></div>
               <ul class="nav nav-pills nav-stacked">
                <?php
                    include "cs234DbConnect.inc.php";
                    $dbc =  mysqli_connect(DBHOST, DBUSER, DBPWD, DBNAME);
                    $error = mysqli_connect_error();
                    if(mysqli_connect_errno()){
                        echo "Failed to connect to MYSQL: " . mysqli_connect_error();
                    }
                    $result = mysqli_query($dbc, "SELECT CategoryName FROM site7_categories") or die(mysqli_error($dbc));
                    while($list = mysqli_fetch_array($result)){
                        echo "<li>" . $result['CategoryName'] . "</li>";
                    }
                    ?>

            </ul>
         </div>

1 Answer 1

1

You should use $list['CategoryName'] instead of $result['CategoryName'].

while($list = mysqli_fetch_array($result)){
    echo "<li>" . $list['CategoryName'] . "</li>";
}
Sign up to request clarification or add additional context in comments.

1 Comment

Oh wow, simple mistake, how would I give each of those a dummy link if you don't mind? Thank you for pointing that out by the way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.