Hi. I want to create a search form using the drop down list and checkbox. First, the users have to select from drop down list whether they want to search by date or id. After that, for example, a new pair of drop down list will display for the users to choose the start date and end date. Second, the users have to check the checkbox to make sure what type of information that they want to filter. I have done the form for searching but I don't know How to do the searching script. All the data will be retrieved from MySQL database. Below is parts of the code. Thanks in advance for any help.

<td class="fontBold">Search By:</td>					
<td><select name="search" id="search" class="font" onChange="display(this, 'date', 'id');">
<option value="">-- Please select --</option>
<option value="date">Date</option>
<option value="id">ID</option>
</select>
</td>
</tr>
<table width="1000" border="1" align="center">
<tr>		  
<td class="fontBold">Filter:</td>
<td><input type="checkbox" name="check_filter" id="check_filter" value="yes" onClick="check(document.search.check_list)">Check All</td>
</tr>
<tr>
<td><input type="checkbox" name="check_list" id="no" value="1">No</td>
<td><input type="checkbox" name="check_list" id="id" value="2">ID</td>
<td><input type="checkbox" name="check_list" id="type" value="3">Type</td>
<td><input type="checkbox" name="check_list" id="address" value="4">Address</td>
</tr>
<tr>
<td><input type="checkbox" name="check_list" id="status" value="5">Status</td>
<td><input type="checkbox" name="check_list" id="start_date" value="6">Start Date</td>
<td><input type="checkbox" name="check_list" id="end_date" value="7">End Date</td>
<td><input type="checkbox" name="check_list" id="amount" value="8">amount</td>
</tr>
//...
//...
//...others type of filter
</table>

take the value from the dropdown and checkboxes and simply throw them into a SELECT query

Thanks for the reply. But I just want to display all the data based on the type of filter. For example, if the user just check the checkbox for ID, start date and end date, then I just have to display this three items. If just thrown in the select table then the table sure will have empty columns. I just want to display all the selected items and display them in table form.

take the value from the dropdown and checkboxes and simply throw them into a SELECT query

huh ? you will take the user input to form the SELECT query.
for example when you have checkbox, set value="1" so when they are checked you would have $_POST set as 1

You use the $_POST to form your SELECT query.

So if there are 4 columns, and only 2 are checked, you can easily use the $_POST to form a query like "SELECT col1, col2 FROM tbl" or "SELECT * FROM tbl WHERE col1 = 'something' AND col2 = 'something'" or whatever you want to.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.