Hi,
I am using this form in Chronoconnectivity component
The HTML Coding is
This is the value displaying echo page coding.
And the MySql Where condition page code is
See the attachment
Now if I select the Looking For : as Groom click search button I get the All the Groom data Correctly
If I select the Looking For : as Groom and Marital Status: as Single and click search
I get the All the Groom and All the data with marital status with single even from the Bride.
How will i check if more than one search is selected and how will i query for it?
I am using this form in Chronoconnectivity component
The HTML Coding is
<html>
<head>
<title>Advance Search</title>
</head>
<body>
<div style="margin-top:10px;">
<table>
<tbody>
<tr>
<td>
Looking For :
</td>
<td>
<input type="radio" name="lookingfor" value="Groom" /> Groom
<input type="radio" name="lookingfor" value="Bride" /> Bride
</td>
</tr>
</div>
<tr>
<td>
<div style="margin-top:10px;">
Age in Years : </td><td>
<select name="age">
<option value="0">Select</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
</select>
to
<select name="toage">
<option value="0">Select</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
</select>
</div>
<div>
</td>
</tr>
</div>
<div style="margin-top:10px;">
<tr>
<td>
Marital Status:</td><td>
<input type="radio" name="maritalstatus" value="Single" /> Single
<input type="radio" name="maritalstatus" value="Divorced" /> Divorced
<input type="radio" name="maritalstatus" value="Seperated" /> Seperated
</td>
<tr>
</div>
<div> </div>
</br> </br>
<div style="margin-top:10px;">
<tr>
<td>
Looks:</td><td>
<select name="looks">
<option value="0">Select</option>
<option value="Slim">Slim</option>
<option value="Average">Average</option>
<option value="Not too Fat">Not too Fat</option>
<option value="Fat">Fat</option>
</select>
</td>
</tr>
</div>
<div> </div>
<div style="margin-top:10px;">
<tr>
<td>
Mother Tongue:</td>
<td>
<input type="radio" name="mothertongue" value="Tamil" /> Tamil
<input type="radio" name="mothertongue" value="Telugu" /> Telugu
<input type="radio" name="mothertongue" value="Kannada" /> Kannada
<input type="radio" name="mothertongue" value="English" /> English
</td>
</tr>
</div>
<div style="margin-top:10px;">
<tr>
<td>
Education:</td><td>
<select name="education">
<option value="0">Select</option>
<option value="No Education">No Education</option>
<option value="High School">High School</option>
<option value="Under Graduate">Under Graduate</option>
<option value="Graduate">Graduate</option>
<option value="Post Graduate">Post Graduate</option>
</select>
</td>
</tr>
</div>
<div style="margin-top:10px;">
<tr>
<td>
Occupation</td><td>
<select name="occupation">
<option value="0">Select</option>
<option value="Self Employed">Self Employed</option>
<option value="Business">Business</option>
<option value="Corporate">Corporate</option>
<option value="Government">Government</option>
<option value="Un Employed">Un Employed</option>
<option value="Profession">Profession</option>
</select>
</td>
</tr>
</div>
<div style="margin-top:10px;margin-bottom:20px;">
<tr>
<td ></td>
<td>
<input type="submit" value="Search" height = "20px" width= "40px" />
</td>
</tr>
<tr>
<td>
<div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</body>
</html>
This is the value displaying echo page coding.
<?php
echo "<table width=800 border=0 style ='background-color:#EDEBE7;'>\n";
print "<tr>\n";
echo " <td style='font-weight:bold;font-size:12px;vertical-align:top;font-family:Arial,Helvetica,sans-serif;'> {profilename}</h6><br><img src={profilephoto} height='100px' width='100px'></img> </td>";
echo " <td style='width:400px;vertical-align:top;text-align:justify;'><b>About Myself: </b><br> {about_myself} </td>";
echo " <td style='vertical-align:top;'><b>Age: </b> {age}
<br><b>Education: </b> {education}
<br><b>Occupation: </b> {occupation}
<br><b>Annual Income: </b> {annual_income}
<br><b>Martial Status: </b> {martial_status}
</td>";
print "</tr>";
print "<tr>\n";
echo " <td></td>";
echo " <td></td>";
echo " <td ><a href=index.php?option=com_chronocontact&chronoformname=detailview&vname={id} style ='float:right;'><input type='submit' value='More Info' /> </a></td>";
print "</tr>";
echo "</table>\n";
echo "<br>";
?>
And the MySql Where condition page code is
<?php
$lookingfor = JRequest::getVar('lookingfor', '', 'post');
$age = JRequest::getVar('age', '', 'post');
$toage = JRequest::getVar('toage', '', 'post');
$maritalstatus = JRequest::getVar('maritalstatus', '', 'post');
$looks = JRequest::getVar('looks', '', 'post');
$mothertongue = JRequest::getVar('mothertongue', '', 'post');
$education = JRequest::getVar('education', '', 'post');
$occupation = JRequest::getVar('occupation', '', 'post');
if ($lookingfor == 'null' && $age == 0 && $toage == 0 && $maritalstatus == 'null' && $looks == 0 && $mothertongue == 'null' && $education == 0 && $occupation == 0 )
{
echo "WHERE `brideorgroom`= 'dfgjkfdlg' ";
}
else
{
echo "WHERE `brideorgroom` = '$lookingfor' OR `martial_status` = '$maritalstatus' OR `looks` = '$looks' OR `mother_tongue` = '$mothertongue' OR `education` = '$education' OR `occupation` = '$occupation' OR `age` >= '$age' AND `age` <= '$toage'";
}
?>
See the attachment
Now if I select the Looking For : as Groom click search button I get the All the Groom data Correctly
If I select the Looking For : as Groom and Marital Status: as Single and click search
I get the All the Groom and All the data with marital status with single even from the Bride.
How will i check if more than one search is selected and how will i query for it?