Jump to content

search database table with checkbox values


Matt G

Recommended Posts

Hello everyone,

Im fairly new to HTML, PHP and MySQL and I have been researching for weeks to find a script that allows me to search specified database tables for checkbox values.. I have come across a number of articles and forums that discuss methods of retrieving/displaying submitted checkbox values &/or populating checkbox forms with database values; but none have explained how to conduct a MySQL table search using selected(checked) checkbox values..

 

I have a html checkbox form that has values: RED, BLUE, GREEN, SHIRTS, PANTS, SHORTS; my RETAIL DATABASE consists of two tables( each table represents a specific retail store) Store 1(Table_1) and Store 2(table_2);

Rows within the table consist of a ID (Primary& Auto_INT); Product_Name(Varchar) and a Product_Description(Text)..

 

For example: I would like the checkbox form to search the "Product_Descriptions" of  "table_1" and return the "Product_Name(& description)" from MySQL; but Im having sooo much trouble getting started or finding a usable reference... Here's what I got so far:

 


<form action="...php" method="post"
name="search_form" onsubmit="return Checkckeckboxes(this);">

<input type="checkbox" name="search['table_1']" value="blue" id="search1"/> Blue<br/>
<input type="checkbox" name="search['table_1']" value="red" id="search2"/> Red<br/>
<input type="checkbox" name="search['table_1']" value="green" id="search3"/> Green<br/>
<input type="checkbox" name="search['table_1']" value="shirts" id="search4"/> Shirts<br/>
<input type="checkbox" name="search['table_1']" value="pants" id="search5"/> Pants<br/>
<input type="checkbox" name="search['table_1']" value="shorts" id="search6"/> Shorts<br/>
<input type="submit" value="search"/>
</form>

//not sure what information is to be placed in the "id" section..if any

 

Database name is: RETAIL_STORES

 

Table_1 ( represents store number one)

 

Id (primary, auto int)            //i.e. 1

Product_Name (Varchar)        //i.e. Golf Shorts

Product_description (Text)    //i.e. Green, Shorts, etc

 

Table_2 (represents store number two)

 

Id (primary, auto int)          //i.e. 1 

Product_Name (Varchar)      //i.e. basketball shirt

Product_description (Text)  //i.e. red, shirt

 

I want this form to search for selected(checked) values in Table_1 via product_Description and display the Product_Name and description to the user.. But im sure my form parameters have NOT accomplished this and I need code help to achieve my goal.. I know someone on this forum can help or at least get me started in the right direction..PLEASE HELP!!!!!! :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.