Sorry to bother you about this I know it must be something very simple, I've been at it for a day with no avail... please help!
Its a small form that displays some letters, as the user clicks I neet them to go away and display the results from a db.
here the code... (deleted db data for security)
----
PHP Code:<?php
?>
<html>
<head><title>Glossary</title></head>
<body>
<?php
$user="pixeldg_cturnb";
$host="localhost";
$password="";
$database = "pixeldg_pixeldb";
$connection = mysql_connect($host,$user,$password)
or die ("couldn't connect to server");
$db = mysql_select_db($database,$connection)
or die ("Couldn't select database");
$letra = htmlentities($_POST["letra"], ENT_QUOTES);
$lad = "$letra"."%";
$query = 'SELECT term,definition FROM glossary WHERE term like "$letra"';
$result = mysql_query($query) or die ("Couldn't execute query.");
/* Inputing data from the form */
if (!isset($_SESSION["letra"])) // If no session is set, let's show the form
{
echo '<form action="" method="post">
<table cellpadding = 3 cellspacing = 3 border = 1 width = 30%>
<tr>
<td>
<input type = radio value = "A" name = letra> A
<br>
<input type = radio value = "B" name = letra> B
</td>
<tr>
<td><input type = submit value = "display"></td>
</table></form>
';
$_SESSION["letra"] = $_POST["letra"];
}
else
{
/* Display results in a table */
echo "<table cellpadding = 3 cellspacing = 0 border = 0 width = 450>
<tr><td colspan='3'><hr></td></tr>";
while ($row = mysql_fetch_array($result))
{
extract($row);
echo "<tr>\n
<td valign = topwidth = 100 class = stit>$term</td>\n
<td class = txt>$definition</td>\n
</tr>\n
<td colspan = 2><hr width = 50%></td></tr>";
}
echo "</table>";
}
mysql_close();
?>


Reply With Quote
Bookmarks