Im working on this searh field and i finally can search from the database using an entered name or national ID no, when i press the find button. But i dont know how to incorporate radio buttons to be submitted to execute a query. can someone help me . my code is below.
what i want is for example if i enter an id card no and click on a radio button as well, so and so id who has completed successfully (yes), needs to be resulted and displayed.
how do i do this?
can there be 2 separate queries or what?
here is the code
html search form
<html>
<strong>SEARCH</strong><br/>
<form style="background-color:#F2F2F2; padding:10px; border:1px solid; border-color:#084B8A; width:650px;" action="http://localhost/sdc/?q=node/2" method="POST">
<table>
<tr>
<td>Name:</td><td width="300"><input type="text" size="60" name="q"/></td>
</tr>
<tr>
<td>NIC No:</td><td width="150"><input type="text" size="40" name="id"/></td>
</tr>
<tr>
<td>Course:</td>
<td>
<select>
<option>ALL</option>
<option>CTHE</option>
</select>
</td>
</tr>
<tr>
<td>Date of Course:</td><td width="60"><input type="text" size="20" /></td>
</tr>
<tr>
<td>Completed Successfully:</td>
<td width="500">
<input type="radio" name="cs">YES</radio> <input type="radio" name="cs">NO</radio> <input type="radio" name="cs" checked>ALL</radio>
</td>
</tr>
<tr>
<td>Current Course Participant:</td>
<td width="500">
<input type="radio" name="pm">YES</radio> <input type="radio" name="pm">NO</radio> <input type="radio" name="ccp" checked>ALL</radio>
</td>
</tr>
</table>
<input type="submit" value="FIND" name="find" style="float:right;" class="up" onmouseover="this.className='over'" onmouseout="this.className='up'"/>
</form>
</html>
the php :=
<?php
$q=$_POST['q']; //Get the search text
$id=$_POST['id'];
/*$cs=$_POST['cs'];
echo $cs;*/
if (isset($_POST['find'])) {
$cs = $_POST['cs'];
print $cs;
}
$con = mysql_connect('localhost', 'root', ''); //connect to the database
if (!$con) //if cannot connect to the database, terminate the process
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("sdc_cpds", $con); //Select the databse
$sql="SELECT * FROM course_participant WHERE name='".$q."' || nic LIKE '$id'"; //Select Query
//echo $sql;
$result = mysql_query($sql);//execute the query and get the result
$num_rows= mysql_num_rows($result); //get the count of the result
if($num_rows >0) //If there is a result, display it
{
while($row = mysql_fetch_array($result))
{
echo $row['name'] ; echo " ";echo $row['nic'] ;echo " "; echo $row['res_address'] ;echo " ";echo $row['contact_no'] ;echo " ";echo $row['email'] ;echo " ";echo $row['gender'] ;echo " ";echo $row['age'] ;echo " ";echo $row['marital_status'] ;echo " ";echo $row['university'] ;echo " ";echo $row['facdept'] ;echo " ";echo $row['course'] ;echo " ";echo $row['course_date'] ;echo " ";echo $row['reg_date'] ;echo " ";echo $row['payments'] ;echo " ";echo $row['completion'] ;
echo "<br>";
}
}
if (isset($_POST['find'])) {
$cs = $_POST['cs'];
if ($cs == 'yes') {
$yes = 'checked';
echo "Completed";
}
else if ($cs == 'no') {
$no = 'checked';
echo "Current";
}
}
else // If no result found
{
echo "No result found!"; //Display the "not found" message
}
mysql_close($con); //Close the database connection
?>
ive gone thru so many tutorials trying to fix this - please help me out