this is all to do with search. People search book by call_no, author, title...etc.
I am running into a problem. when i tried to write the code for this search functions..here i explain it in details...
i let the users to select one of the 5 radio buttons namely call_no, author, isbn, category,title.
I place 5 text box, one against each radio button to take the value that the user enters after he made the selection.
Then he hits the search button...my code first checks which radio button is selected, and then takes the value from the corresponding text box and send it to my php file that will process back the result and display it to the users.
so, depending on the selection my sql statement will change:
when the selected radio button is call_no it would be:
Code: Select all
<?php
$sql = "Select * FROM book WHERE call_no=('{$_POST['call_no']}')";
?>when the selected radio button is author it would be:
Code: Select all
<?php
$sql = "Select * FROM book WHERE call_no=('{$_POST['author']}')";
?>and so on........................
Now, i m not sure how to let my code to check which radio button is selected.
the following code i have copied from my html page:
Code: Select all
<?php
<td width="15%">
<p align="right"><input type="radio" value="V1" checked name="R1"></p>
</td>
<td width="6%">Call No</td>
<td width="51%"><input type="text" name="T1" size="20"></td>
<td width="57%"><a href="http://localhost/insertbook.php"><font color="#0000FF">Insert
Entry</font></a></td>
</tr>
<tr>
<td width="15%">
<p align="right"><input type="radio" name="R1" value="V2">
</td>
<td width="15%">
Author
?>Here, the first radio button is selected by default, so it has an extra property PHP:
<?php checked name="R1" ?>
I wonder if i should let the code to check "checked" value...
Am i thinking the right way?
If you know more specific and more effective way please let me know.
Code: Select all
// Added PHP tags for eyecandy. --JAM