passing variables from input form to php page
Posted: Thu Jul 24, 2008 12:51 pm
hi
the input form below passes "category" selection to a listings.php page. The "Category" variable doesn't seem to be passing from the input form to the $cat = $_POST['category'] on the listings.php (code below)page.
Any ideas?
here is the listing.php
the input form below passes "category" selection to a listings.php page. The "Category" variable doesn't seem to be passing from the input form to the $cat = $_POST['category'] on the listings.php (code below)page.
Any ideas?
Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body>
<form name="listing.php" method="post">
<table border="1">
<tr>
<td> category</td>
<td> <select name= "category">
<option value=" " selected> Select Category</option>
<option value="Voluntary Filing">Voluntary Filing</option>
<option value="Mandatory Filing">Mandatory Filing</option>
<option value="Development">Development</option>
</select>
<input type="submit" name="submit" value="search">
</td>
</tr>
</table>
</form>
</body>
</html>
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<?php include ('../admin/config.php'); ?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
</head>
<body>
<?php
$cat = $_POST['category'] ;
$result = mysql_query("SELECT projects.id, projects.name, projects.cat FROM projects WHERE cat='$cat' ",$dblink);
echo "<table border=\"0\">\n" ;
while ($row = mysql_fetch_assoc($result)){
echo "<tr>\n" ;
foreach($row as $value) {
echo "<td>\n" ;
echo $value;
echo "</td>\n" ;
}
echo "</tr>\n" ;
}
echo "</table>\n" ;
?>
</body>
</html>