Hello guys, I'm new to PHP and web development in general so go easy on me.
Here's the sitrep. I created a database on a mysql server, it has 1 field. I want to create an html table dynamically when users click on a link, and display the data from the mysql database.
I found several scripts online for doing this but none have worked. This is what I have so far:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<?php
$con = mysql_connect("myservername","myusername","mypassword");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("bands", $con);
$result = mysql_query("SELECT * FROM list WHERE name LIKE \'A%\' ORDER BY name");
echo "<table border='1'>
<tr>
<th>Band Name</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['name'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysql_close($con);
?>
<body>
</body>
</html>
AND this is the actual output I get when I open this page,
Band Name "; while($row = mysql_fetch_array($result)) { echo ""; echo "" . $row['name'] . ""; echo ""; } echo ""; mysql_close($con); ?>
So obviously somewhere I've made a grievous error, please help! Sad Thank you