I'm working on one site where I am trying to connect to an SQL database and post a SQL field inside a <div>
. The <div>
is inside a while
loop.
I think I have connected successfully to the database. But, I'm unable to show id field in the header. I am newbie to PHP & SQL and can't figure it out. Here is my code below:
<?php
$db_host = "localhost";
$db_username = "user192";
$db_pass = "xxxx";
$db_name = "sound-library";
@mysql_connect("$db_host","$db_username","$db_pass") or die ("couldnt connect to sql");
@mysql_select_db ("$db_name") or die ("cant find database");
$query = "select * from sound-library";
$queryResult=mysql_query($query);
$numrows=mysql_num_rows($queryResult);
?>
while($row = mysql_fetch_assoc($queryResult)) {
<div class="audio-module-parent">
<div class="audio-module-header">
<?php
<h1> <?php echo $row['id']?> </h1>
</div>
<div class="audio-module-preview"></div>
<div class="audio-module-download">Download</div>
<div class="audio-module-tutorial">Watch Tutorial</div>
</div>
?>