Hello,
I am trying to display information from a DB onto an html page. Using this code,
the table displays fine, but none of the information shows up, and the following code is displayed on the html page:
then the table, with things like " . $row[0] . " as one cell in each column, and then below the table
I've seen something like this before, but I don't know how to fix it. The hl_placement_programs is a table in my DB. I'm confused because it seems to be connecting to the DB, but can't get info? Please help; it's probably some tiny thing I messed up on.
Thanks!
Apologies if this goes in the MySQL section. It's in a PHP file, so I figured I'd put it here.
I am trying to display information from a DB onto an html page. Using this code,
PHP Code:
<?php
.
.
.
$connection = mysql_connect($db_connection, $db_user, $db_pass)
or die ("Unable to connect to SQL");
// select DB
mysql_select_db("my_db") or die ("Unable to connect to DB");
//query test
$query = "SELECT * FROM hl_placement_programs";
$result = mysql_query($query, $connection)
or die ("Error in query: $query. " . mysql_error());
//check if records were returned
if (mysql_num_rows($result) > 0)
{
echo "<table width = 100% border = 1>";
echo "<tr><td><b>Name</b></td><td><b>Street</b></td><td>
<b>City</b></td><td><b>State</b></td><td><b>Zipcode</b>
</td><td><b>Phone Number</b></td><td><b>Website</b></td></tr>";
while ($row = mysql_fetch_row($result))
{
echo "<tr>";
echo "<td>" . $row[0] . "</td>";
echo "<td>" . $row[1] . "</td>";
echo "<td>" . $row[2] . "</td>";
echo "<td>" . $row[3] . "</td>";
echo "<td>" . $row[4] . "</td>";
echo "<td>" . $row[5] . "</td>";
echo "<td>" . $row[6] . "</td>";
echo "</tr>";
}
echo "</table>";
}
else
{
//print error message
echo "Oh dear. No rows were found!";
}
//once processing is complete
//free result set
mysql_free_result($result);
//close connection
mysql_close($connection);
?>
0) { echo ""; echo ""; while ($row = mysql_fetch_row($result)) { echo "";
echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; } echo "
then the table, with things like " . $row[0] . " as one cell in each column, and then below the table
"; } else { //print error message echo "Oh dear. No rows were found!"; }
//once processing is complete //free result set mysql_free_result($result);
//close connection mysql_close($connection); ?>
I've seen something like this before, but I don't know how to fix it. The hl_placement_programs is a table in my DB. I'm confused because it seems to be connecting to the DB, but can't get info? Please help; it's probably some tiny thing I messed up on.
Thanks!
Apologies if this goes in the MySQL section. It's in a PHP file, so I figured I'd put it here.
Comment