Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Jul 2010
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Multiple Element Search

    Hi,

    I am using a Search form. Where I have Multiple elements if I select any of the value and click the Search button the Related data should be displayed.

    For clear idea see the attachment.

    I used the Mysql Query Where condition like this.
    WHERE `brideorgroom` = '$lookingfor' OR `city` = '$city' OR `state` = '$state' OR `occupation` = '$occupation' OR `age` >= '$age' AND `age` <= '$toage'
    But this is not working good when i select more than one element for search.

    Please provide me a better solution.

    Regards,
    Shoaib.
    Attached Thumbnails Attached Thumbnails Multiple Element Search-screenshot.jpg  

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,852
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    But this is not working good when i select more than one element for search.
    Please post your complete code. Also echo your query to make sure that the variables are getting correctly substituted there.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    New to the CF scene
    Join Date
    Jul 2010
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Smile

    Hi,

    I am using this form in Chronoconnectivity component in joomla.

    The HTML Coding is
    PHP Code:
    <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 Code:
    <?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:&nbsp;&nbsp;</b><br> {about_myself} </td>";

    echo 
    " <td style='vertical-align:top;'><b>Age:&nbsp;&nbsp;</b>&nbsp;&nbsp; {age}

    <br><b>Education:&nbsp;&nbsp;</b>&nbsp;&nbsp; {education}

    <br><b>Occupation:&nbsp;&nbsp;</b>&nbsp;&nbsp; {occupation}

    <br><b>Annual Income:&nbsp;&nbsp;</b>&nbsp;&nbsp; {annual_income}

    <br><b>Martial Status:&nbsp;&nbsp;</b>&nbsp;&nbsp; {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 Code:
    <?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 == && $toage == && $maritalstatus == 'null' &&  $looks == && $mothertongue == 'null' && $education == && $occupation == )
    {
    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?


    Regards,
    Osmodels.
    Attached Thumbnails Attached Thumbnails Multiple Element Search-screenshot-1.jpg  

  • #4
    New to the CF scene
    Join Date
    Jul 2010
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Friendly bump....

    Regards,
    Shoaib.

  • #5
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,852
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Also echo your query to make sure that the variables are getting correctly substituted there.
    Where's your final complete query?
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #6
    New to the CF scene
    Join Date
    Jul 2010
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Smile

    Hi,

    Here in Chronoform we dont need to write the whole query.

    PHP Code:
    if ($lookingfor == 'null' && $age == && $toage == && $maritalstatus == 'null' &&  $looks == && $mothertongue == 'null' && $education == && $occupation == )
    {
    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'";




    This echo Where Condition Does its job.

    I dont have any bugs in this if I select any one field and search for it. It gives me the correct records.

    But if I select more than one Field for Search It does not gives me the correct search result.


    My question how should I write the code for More than one field is selected.

    As I have 8 Fields in Search it gives me 8*7*6*5*4*3*2*1 Probility of search. Should I write "IF" Condition For All Or Is there Any Short Method For Selecting only the "Filled Field ( Which is not empty)" And Search With it.


    Regards,
    Shoaib


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •