Note that there are some explanatory texts on larger screens.

plurals
  1. POSearch and Results Page
    primarykey
    data
    text
    <p>I'd like to get some help with my search script. A little about the site: I have registered users and when they register they select their user type (ie Nanny, Homecare, Daycare). Right now I have a search bar and visitors can input their zip code and the results page shows everything in the database with that zip code. Current form:</p> <pre><code>&lt;form id="form1" name="form1" method="get" action="results.php"&gt; &lt;p&gt; &lt;label&gt;Search for&lt;input type="text" name="Search" id="Search" /&gt;&lt;/label&gt; &lt;label&gt; &lt;select name="Field" id="Field"&gt; &lt;option value="Zip"&gt;Zip&lt;/option&gt; &lt;/select&gt; &lt;/label&gt; &lt;input type="submit" name="button" id="button" value="Search" /&gt; &lt;/p&gt; </code></pre> <p></p> <p>What I would like to do is to have it where users enter their zip code and select Nanny, Homecare, or Daycare from a drop down and the results shows only that type in the search results instead on everything within that zip.</p> <p>How I want the form to look:</p> <pre><code>&lt;form id="form1" name="form1" method="get" action="results.php"&gt; &lt;p&gt; &lt;label&gt;Search for&lt;input type="text" name="Search" id="Search" value="Zip" /&gt;&lt;/label&gt; &lt;label&gt; &lt;select name="Field" id="Field"&gt; &lt;option value="Nanny"&gt;Nanny&lt;/option&gt; &lt;option value="Homecare"&gt;Homecare&lt;/option&gt; &lt;option value="Childcare"&gt;Childcare&lt;/option&gt; &lt;/select&gt; &lt;/label&gt; &lt;input type="submit" name="button" id="button" value="Search" /&gt; &lt;/p&gt; &lt;/form&gt; </code></pre> <p>The php:</p> <pre><code>&lt;?php require_once('scripts/_config.php'); if(isset($_GET['Field'])){ $searchQ1=mysql_query("SELECT `First_Name`,`Last_Name`,`Nanny`,`Homecare`,`Childcare`,`City`,`State`,`Zip`,`userID` FROM `sys_profile` WHERE `".$_GET['Field']."` LIKE '".$_GET['Search']."';"); }else{ $searchQ1=mysql_query("SELECT `First_Name`,`Last_Name`,`Nanny`,`Homecare`,`Childcare`,`City`,`State`,`Zip`,`userID` FROM `sys_profile` WHERE `userID`!=0;"); } ?&gt; </code></pre> <p>How do I change the php so that the search results displays only nannies within the entered zip, or childcare in the entered zip, etc? Right now the php shows everything in that zip and when I change the form to the second example it still doesn't work because I'm not sure how to adjust the search query. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload