Display that fits with parameters
I have made database that contains some information. Want to do is to retrieve and display data that fits with parameters like:
开发者_如何转开发if i select green from dropdown list, it will display only information about cars that are green. Also "kõik" means like all.
Here is form that im using.
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body align="center" style="margin-top:200px;">
<table border="1" align="center">
<tr>
<td>
<form action="retrieve.php" method="get">
Rass:
<select name="rass">
<option value="ebony">Ebony</option>
<option value="Valge">Valge</option>
<option value="Aasia">Aasia</option>
</select> <br />
<input type="submit" value="lisa" />
</form>
</td>
</tr>
</table>
</body>
</html>
Here is php that used to show all data.
<?php
$connect = @mysql_connect ("localhost", "root", "") or die("Fail!!!! :D:D:D");
mysql_select_db("tibid") or die("selline andmebaas puudub");
$query = mysql_query("select * from test");
$num_rows = mysql_num_rows($query);
if($num_rows > 0){
{while($row = mysql_fetch_assoc($query))
echo
$row['rinnad']. "<br>"
.$row['juuksed']."<br>"
.$row['silmad']."<br>"
.$row['rass']."<br>
<hr>
";}
}else{
echo "Andmebaas on tühi";
}
?>
Link to this kind tutorial would be helpful. Thank you
I think you are looking for WHERE
. So your query would be:
select * from cars where color = '$color'
where $color
is escaped $_POST['color']
passed from your form.
精彩评论