Trouble reading table in MySQL
I am trying to simply read a MySQL table names "songs" and write the
"title" column into HTML. I am just beginning with MySQL, so can anyone
explain why it is not working?
The (single-column) SQL table looks like this:
+---------+
| TITLE |
+---------+
| Hello |
| World |
| Table |
| Value |
+---------+
Here is the code I am using in the PHP page
<ul>
<?php
$dbc = mysqli_connect('localhost', 'root', 'pass', 'music');
$query = "SELECT title FROM songs";
$result = mysqli_query($dbc, $query);
$row = mysqli_fetch_array($result);
while ($row = mysqli_fetch_array($result)) {
echo '<li id="' . $row['title'] . '" data-title="' .
$row['title'] . '">';
echo '<img class="X" src="X.png" style="width: 14px; margin:
2px 0 -2px -4px; display: none;" />';
echo '<span class="title">' . $row['title'] . '</span>';
echo '</li>';
}
?>
</ul>
There is no output.
No comments:
Post a Comment