Reputation: 659
i created a buy.html:
<form action="result.php" method="post">
<input type="radio" Name="ptype" />aaa<br/>
<input type="radio" Name="ptype" />bbb<br/>
<input type="submite" value="Submit" />
then i created a result.php
<?php
...
...
$sql="SELECT address, ptype, price FROM property WHERE ????"
?>
"aaa" and "bbb" are the radio buttons value which are a type of "ptype" in property table
so if i select "aaa", i want to do a query for rows with "aaa" in ptype. how can i do that?
Upvotes: 0
Views: 107
Reputation: 854
You have to pass to input value attribute your property id. Then select from MySQL by id column. $id = $_POST['id']. Don't forget to prepare/sanitize data
$sql="SELECT address, ptype, price FROM property WHERE id=$id"
Upvotes: 1
Reputation: 131
You must set value of input element
<form action="result.php" method="post">
<input type="radio" Name="ptype" value="a" />aaa<br/>
<input type="radio" Name="ptype" value="b" />bbb<br/>
<input type="submit" value="Submit" />
</form>
THEN
<?php
$ptype = $_POST['ptype'];
$sql="SELECT address, ptype, price FROM property WHERE ptype ='" . $ptype . "'";
?>
Upvotes: 4