Forum Moderators: coopster
PHP SCRIPT
<?php
$conn = mysql_connect("localhost","","");
mysql_select_db("models",$conn);
$person = $_POST['sex'];
$myage = $_POST['dob'];
$resultID = mysql_query("SELECT * FROM $person WHERE age = $myage ",$conn);
print "<table border = 1><tr><th>id</th>";
print "<th>name_first</th><th>name_last</th>";
print "<th>age</th><th>height</th><th>weight</th>";
while ($row = mysql_fetch_row($resultID))
{
print "<tr>";
foreach ($row as $field)
{
print "<td>$field</td>";
}
print "</tr>";
}
print "</table>";
mysql_close($conn);
?>
_____________________________________________________________
HERE IS MY HTML FORM
_____________________________________________________________
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form name="form1" method="post" action="firstconnect.php">
<p>
<select name="sex" id="sex">
<option>--</option>
<option value="male" selected>male</option>
<option value="female">female</option>
</select>
</p>
<p>
<select name="dob" id="dob">
<option>--</option>
<option value="48">48</option>
<option value="13">13</option>
<option value="10">10</option>
<option value="10,11,12,13">10 - 13</option>
</select>
</p>
<p> </p>
<p> </p>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
</form>
</body>
</html>
Change the option value from:
<option value="10,11,12,13">10 - 13</option>
to:
<option value="10-13">10 - 13</option>
In your php file delete the " $resultID = mysql_query("SELECT * FROM $person WHERE age = $myage ",$conn); " statement and add the stuff below.
if($myage == '10-13'){
$resultID = mysql_query("SELECT * FROM $person WHERE age>=10 and age<=13",$conn);
}
else {
$resultID = mysql_query("SELECT * FROM $person WHERE age = $myage ",$conn);
}
That should give you the range of ages that you need. This would need to be changed if you wanted to add more ranges like 14-16, 17-19, etc... If you need help with that, let me know.
HTH,
Conor