I need help and thank you in advance for any advice. I'm new to Php and Mysql. I've put three drop down menus in one cell of a table and I want to display results of a simple query (4 fields per record) in another cell of the table. Only one selection (one drop down) is in play for each search. There should be about 10 results for each search. In tests, I've been able to open the database. This is as far as I have been able to proceed so far (Also, I'm also not sure if I need something in "action"):

            <form id="form4" name="form1" method="post" action="">
      <label for="Friday"></label>
      <div align="center">
        <select name="Friday2" id="Friday">
          <option value="0">Block # - Day - Time</option>
          <option value="100">Block 100 - Fri 7:15-7:30</option>
          <option value="200">Block 200 - Fri 7:30-7:45</option>
          <option value="300">Block 300 - Fri 7:45-8:00</option>
          <option value="400">Block 400 - Fri 8:00-8:15</option>
          <option value="500">Block 500 - Fri 8:15-8:30</option>
          <option value="600">Block 600 - Fri 8:30-8:45</option>
          <option value="700">Block 700 - Fri 8:45-9:00</option>
          <option value="800">Block 800 - Fri 9:00-9:15</option>
          <option value="900">Block 900 - Fri 9:15-9:30</option>
          <option value="1000">Block 1000 - Fri 9:30-9:45</option>
          <option value="1100">Block 1100 - Fri 9:45-10:00</option>
          <option value="1200">Block 1200 - Fri 10:00-10:15</option>
          <option value="1300">Block 1300 - Fri 10:15-10:30</option>
          <option value="1400">Block 1400 - Fri 10:30-10:45</option>
          <option value="1500">Block 1500 - Fri 10:45-11:00</option>
          <option value="1600">Block 1600 - Fri 11:00-11:15</option>
          <option value="1700">Block 1700 - Fri 11:15-11:30</option>
          <option value="1800">Block 1800 - Fri 11:30-11:45</option>

        <input type="submit" name="Friday button2" id="Friday button2" value="Search" />

    <p align="center" class="small"><strong>Saturday Night</strong>       </p>
    <form id="form5" name="form2" method="post" action="">
      <label for="Saturday"></label>
      <div align="center">
        <select name="Saturday2" id="Saturday">
          <option value="0">Block # - Day - Time</option>
          <option value="2100">Block 2100 - Sat 7:15-7:30</option>
          <option value="2200">Block 2200 - Sat 7:30-7:45</option>
          <option value="2300">Block 2300 - Sat 7:45-8:00</option>
          <option value="2400">Block 2400 - Sat 8:00-8:15</option>
          <option value="2500">Block 2500 - Sat 8:15-8:30</option>
          <option value="2600">Block 2600 - Sat 8:30-8:45</option>
          <option value="2700">Block 2700 - Sat 8:45-9:00</option>
          <option value="2800">Block 2800 - Sat 9:00-9:15</option>
          <option value="2900">Block 2900 - Sat 9:15-9:30</option>
          <option value="3000">Block 3000 - Sat 9:30-9:45</option>
          <option value="3100">Block 3100 - Sat 9:45-10:00</option>
          <option value="3200">Block 3200 - Sat 10:00-10:15</option>
          <option value="3300">Block 3300 - Sat 10:15-10:30</option>
          <option value="3400">Block 3400 - Sat 10:30-10:45</option>
          <option value="3500">Block 3500 - Sat 10:45-11:00</option>
          <option value="3600">Block 3600 - Sat 11:00-11:15</option>
          <option value="3700">Block 3700 - Sat 11:15-11:30</option>
          <option value="3800">Block 3800 - Sat 11:30-11:45</option>
        <input type="submit" name="Saturday button2" id="Saturday button2" value="Search" />
    <div align="center">
    <p align="center"><strong>Category</strong>    </p>
    <form id="form6" name="form3" method="post" action="">
      <label for="Categories"></label>
      <div align="center">
        <select name="Categories2" id="Categories">
          <option value="0">Select Item Category</option>
          <option value="1">Arts and Entertainment</option>
          <option value="2">Health and Beauty</option>
          <option value="3">Home and Garden</option>
          <option value="4">Entertainment</option>
          <option value="5">Clothing and Jewellry</option>
        <input type="submit" name="Category Button2" id="Category Button2" value="Search" />
4 Years
Discussion Span
Last Post by AndreRet

I have the above code in one cell of an html table. It is meant to select one "block" of records from a single table in the database. I then need to return the results of the query and display them in another cell of the table (the page has the .php extension). I've tried to find php code for this type of query and display, but haven't been successful. Because I'm very new at this, I'm not even clear of where the php code should be placed. I put some php code in and was only able to display commas, and they were above the table. Also, I got the pop-up box about resending data every time I tried to refresh. These dropdowns are meant to be used multiple times to display various items from the database.


Further to what I have tried, I put the php code, including the opening of the database, and echo statements in the html table cell next to the cell containing the forms. I now realize that this won't work, but I don't know how to get the info from the database into the table cell adjacent to the drop down forms for the search.


I guess you want search records based on some selected value in dropdown

conventional post/get method

1) you create html page as u did tried in ur first post with form elements
2) on submit form, all form elements posted to action page
3) set action page to say process.php
4) in process.php, you use posted form parameters to filter you sql result
5) display filter result

now a days jquery is used to fetch result from server and display in part of page without submiting whole page, but you learn above method first.


Thank you. I'll give this a try. Fingers crossed.


I placed "process.php" in the action. Then I created this file for process.php:

 $con = mysql_connect("localhost","myusername","mypassword");
 if (!$con)
   die('Could not connect: ' . mysql_error());

mysql_select_db("mydatabase", $con);

$result = mysql_query("SELECT * FROM ITEMS
WHERE Block='Post'");

while($row = mysql_fetch_array($result))
   echo $row['ItemNum'] ;
   echo $row['LongDescription'];
   echo "<br />";

When I open Formpage.php (the original page with the drop downs), it takes me to process.php and I see nothing on the page.


Firstly, actioning a form will take you to the form you specified... process.php

You need to get values selected from a select (drop down) to load the next scenario, right?

Try the following -

<select name="Friday2" id="Friday" onchange="this.form.submit();">

              <select name="Friday2" id="Friday">
      <option value="0">Block # - Day - Time</option>
      <option value="100">Block 100 - Fri 7:15-7:30</option>
      <option value="200">Block 200 - Fri 7:30-7:45</option>

                        <option value="0">Block # - Day - Time</option>

                        <option value="<?php 
                            if($_SERVER['REQUEST_METHOD'] == "POST") {
                            //Once a selection has been made, the posted value will be shown...
                            echo $Friday; //Assuming that you have code to capture the value...
                            if($Friday == $Friday) {
                                echo "SELECTED";
                            echo $Friday;

                        <option value="2100">Block 2100 - Sat 7:15-7:30</option>
      <option value="2200">Block 2200 - Sat 7:30-7:45</option>

To get the values across to your process.php form, add hidden text boxes to save the values in your first form -

<input type="hidden" name="hiddenfriday" value="<?=$_POST['Friday2'];?>"/>

In process.php -

$Friday2 = $_POST['Friday2'];
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.