Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8647791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:09:25+00:00 2026-06-12T13:09:25+00:00

Following on from a recent post. I am creating a search function that queries

  • 0

Following on from a recent post.

I am creating a search function that queries a SQL database. The database consists of different types of meat packaging. I have created HTML & PHP code that will search the database and display results using only one form and submit button. But I now want to create a search box that has multiple forms (including three dropdown ones), that when users type in sizes, click a dropdown and type in a id code, they can submit using one submit button and then will be referred to a page that consists of the results that match all three combined.

Can anyone give me some insight about how to go about this? I have tried creating two forms that submit to the same PHP page for results, but one seems to override the other.

Here is my HTML and PHP code currently:

    <body>

    <form action="form2.php" method="post"> 
              Search: <input type="text" name="term" /><br />
    <input type="submit" value="Submit" /> 
    </form> 


</body>

And the PHP code:

   <body>


   <?php
    $con = mysql_connect ("localhost", "root", "");
    mysql_select_db ("delyn_db", $con);

  if (!$con)
    { 
    die ("Could not connect: " . mysql_error());
    }


$term = mysql_real_escape_string($_REQUEST['term']);    

     $sql = "SELECT * FROM delyn WHERE toolcode LIKE '%".$term."%' OR trayheight LIKE
     '%".$term."%' OR delyncode LIKE '%".$term."%' OR description LIKE '%".$term."%' 
      OR trayshape LIKE '%".$term."%' OR traydepth LIKE '%".$term."%' OR traywidth
     LIKE '%".$term."%'";
     $r_query = mysql_query($sql);

if(!$sql)
    {
        echo "could not find";
    }

       while ($row = mysql_fetch_array($r_query)){ 
       echo 'ID: ' .$row['ID']; 
       echo '<br /> Delyn code: ' .$row['delyncode']; 
       echo '<br /> Tool Code: '.$row['toolcode'];
       echo '<br /> Description: '.$row['description']; 
       echo '<br /> Tray range '.$row['trayrange']; 
       echo '<br /> Tray type: '.$row['traytype'];
       echo '<br /> Tray size: '.$row['traysize']; 
       echo '<br /> Tray height: '.$row['trayheight']; 
       echo '<br /> Tray width: '.$row['traywidth']; 
       echo '<br /> Tray depth: '.$row['traydepth'];
       echo '<br /> Tray shape: '.$row['trayshape'];  
       echo '<br /> imagename: '.$row['imagename'];
       echo '<br /> Tray live: '.$row['traylive'] . ' <br /><br />';  
    }


?>

    </body>

Thanks in advance 🙂

Edited php:

  <body>

    <?php
$con = mysql_connect ("localhost", "root", "");
mysql_select_db ("delyn_db", $con);

if (!$con)
    { 
    die ("Could not connect: " . mysql_error());
    }

if(isset($_POST['formSubmit']) )
{
    $varType = $_POST['traytype'];
}

$term = mysql_real_escape_string($_POST['term']);    
$sql = "SELECT * FROM delyn WHERE traytype LIKE '%".$varType."%'";


$r_query = mysql_query($sql);


while ($row = mysql_fetch_array($r_query)){ 
echo 'ID: ' .$row['ID']; 
echo '<br /> Delyn code: ' .$row['delyncode']; 
echo '<br /> Tool Code: '.$row['toolcode'];
echo '<br /> Description: '.$row['description']; 
echo '<br /> Tray range '.$row['trayrange']; 
echo '<br /> Tray type: '.$row['traytype'];
echo '<br /> Tray size: '.$row['traysize']; 
echo '<br /> Tray height: '.$row['trayheight']; 
echo '<br /> Tray width: '.$row['traywidth']; 
echo '<br /> Tray depth: '.$row['traydepth'];
echo '<br /> Tray shape: '.$row['trayshape'];  
echo '<br /> imagename: '.$row['imagename'];
echo '<br /> Tray live: '.$row['traylive'] . ' <br /><br />';  
    }


?>
  </body>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T13:09:27+00:00Added an answer on June 12, 2026 at 1:09 pm

    Why don’t you use multiple inputs on the same form? Something like this:

    <form action="form2.php" method="post"> 
              Search: <input type="text" name="term" /><br />
              Sizes: <input type="text" name="sizes" /><br />
              Select an option: <select name="dropdownselection" ><option...</option></select><br />
              ID Code: <input type="text" name="id" /><br />
    <input type="submit" value="Submit" /> 
    </form>
    

    Then you can access the values in the same way you accessed value entered for the search term.
    Note: you should use label tags for your labels, and use a list to layout your form.

    EDIT: An option tag looks like this:

    <option value="what is posted to the script">What is seen by the user</option>
    

    EDIT: Please remove the condition surrounding the $vartype variable assignment

    EDIT: Use and, not or, in your sql query, since you need both conditions to be true. If you have further questions, please open a new question, since this one is somewhat cluttered. Finally, if you feel this answer has helped you please consider accepting it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Following from this: Every specific weekday, sql and php I got this: deals_bookings.everyWeekDay =
Sometimes I get the following from SQL Server 2005 when executing a stored procedure:
I've been following a tutorial from a recent edition of the Linux Journal which
Following on from my recent question on Large, Complex Objects as a Web Service
Following on from my recent question regarding parsing XML files in Java I have
I'm following this post to make one ipython rule all the virtualenvs. From what
Following from my last question which @Jon Skeet gave me a lot of help
Following from these question Subset sum problem and Sum-subset with a fixed subset size
I have noted the following from a website: The JVM HotSpot memory is split
Is the following From header incorect? // To send HTML mail, the Content-type header

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.