1

I am trying to display all the info in the table but when I query the information then put it into a PHP table it doesn't show any data in the last table. Screenshot

Here is my PHP code for the table

     <table border='1'>
        <tr>
            <th>Ticket ID</th>
            <th>Username</th>
            <th>Message</th>
            <th>Date</th>
            <th>Error #</th>
            <th>Priority</th>
        </tr>

        <?php
        if(!$query){
            die('Invalid query: ' .mysql_error());
        }
        while ($row = mysql_fetch_array($query)) { ?>
            <tr>
                <td><?php echo $row['TicketID']; ?></td>
                <td><?php echo $row['Message']; ?></td>
                <td><?php echo $row['Date']; ?></td>
                <td><?php echo $row['Error']; ?></td>
                <td><?php echo $row['Priority']; ?></td>
            </tr>
        <?php } ?>
    </table>

Here is the PHP code for query

<?php
$server = mysql_connect("localhost", "root", "**password**");
$db = mysql_select_db("minecraft", $server);
$query = mysql_query("SELECT * FROM tickets");
?>

All of my row names are correct but it doesn't want to put the data into that column.

Here is my table structure Table Structure

Austin McCalley
  • 392
  • 1
  • 4
  • 17
  • can you show your mysql table structure? – Sean Jan 02 '17 at 03:01
  • @Sean [Structure](http://i.imgur.com/tSfVDu6.png) – Austin McCalley Jan 02 '17 at 03:03
  • 2
    how about your query – Beginner Jan 02 '17 at 03:03
  • Add that image to your question as an [edit](http://stackoverflow.com/posts/41420897/edit), not as a comment. Also, can you show your `mysql_query()` code. – Sean Jan 02 '17 at 03:04
  • you just forgot `` – Beginner Jan 02 '17 at 03:05
  • 1
    Every time you use [the `mysql_`](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php) database extension in new code **[a Kitten is strangled somewhere in the world](http://2.bp.blogspot.com/-zCT6jizimfI/UjJ5UTb_BeI/AAAAAAAACgg/AS6XCd6aNdg/s1600/luna_getting_strangled.jpg)** it is deprecated and has been for years and is gone for ever in PHP7. If you are just learning PHP, spend your energies learning the `PDO` or `mysqli` database extensions. [Start here](http://php.net/manual/en/book.pdo.php) – RiggsFolly Jan 02 '17 at 03:14
  • @RiggsFolly Thank you for this, my IDE was showing it being deprecated but I didn't know what to replace it with – Austin McCalley Jan 02 '17 at 03:16

1 Answers1

5

You Omitted

<td><?php echo $row['Username']; ?></td>

that should be after

<td><?php echo $row['TicketID']; ?></td>
funsholaniyi
  • 435
  • 2
  • 12