I am trying to retrieve information from an SQL database and return the info in/on the same .php file that has the form buttons. For some reason when I try to connect to the database my file shows up with nothing however.
[CODE]
<html>
<title> This is my PHP/HTML Integrated Test Page</title>
<body>
<br>
<form action=”lab3a.php” method=”POST”>
<input type=”radio” name=”RadioGroup1″ value=”1″>
Display all book records
<br>
<input type=”radio” name=”RadioGroup1″ value=”2″>
Display book records where price is greater than:
<input type=text size=20 maxlength=150 name=”range”>
<br>
<br>
<br>
<input type=submit value=”Submit Query”>
<input type=reset value=”Cancel”>
</form>
<?php
$dbc=mysql_connect(‘frodo’,’jludt’,’memioth8′)
or die (“Could not connect to MySQL.<br>”);
mysql_select_db(‘jludt’) or die(“Could NOT Open DB.<br>”);
if (!isset($_POST[“RadioGroup1”])
die (“</body></html>”);
if ($_POST[“RadioGroup1″] = 1)
{
$query=”SELECT * FROM books”;
}
else
{
$query=”SELECT * FROM books WHERE price > ‘$_POST[range]'”;
}
$result=mysql_query($query);
if (mysql_num_rows($result) > 0)
{
echo “<div align=center>”;
echo “<table width=’50%’ border=1>”;
$first=TRUE;
while ($row=@mysql_fetch_array($result,MYSQL_ASSOC))
{
if ($first)
{
echo “<tr>”;
foreach ($row as $key => $value)
{
echo “<th>$key</th>”;
}
echo “</tr>”;
$first=FALSE;
}
echo “<tr>”;
foreach ($row as $key => $value)
{
echo “<td>$value</td>”;
}
echo “</tr>”;
}
echo “</table>”;
echo “</div>”;
}
else
{
echo “No results from query.<br>”;
}
mysql_close();
?>
</body>
</html>
Does anyone know why this isn’t working or even possibly another way I can get information from an SQL db to show up on the same php page as teh form information???
Thanks ?