Searching DB Assistance

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
facets
Forum Contributor
Posts: 273
Joined: Wed Apr 13, 2005 1:53 am
Location: Detroit

Searching DB Assistance

Post by facets »

Hi Gang,

How would I go about searching multiple tables from a MySQL DB from a 'searchNow' function.
(The form has many submits, like view this, add that etc)

So I'd have multple input criteria,
(12 X)Checkbox and drop down, (2 X)Checkbox and text input.
And 1, some or all might be checked (ticked)

So far I have the HTML sorted, values etc (Example :)

Code: Select all

<input type=&quote;checkbox&quote; name=&quote;paperCategory&quote; id=&quote;checkbox&quote; value=&quote;on&quote;></td>
<td width=&quote;50px&quote;><select name=&quote;paperCategoryId&quote;>
<option value=&quote;&quote;>-- Select Option --</option>
<option value=&quote;1&quote;>Standard</option>
<option value=&quote;2&quote;>Non Standard</option>
<option value=&quote;3&quote;>Non Approved</option>
</select></code>

But i'm unsure on how to set up the function that passes multiple variables depending on what was selected.

Any pointers would be greatly appreciated..

TIA, Will
facets
Forum Contributor
Posts: 273
Joined: Wed Apr 13, 2005 1:53 am
Location: Detroit

Post by facets »

Ok.. So i'm now passing variables to the function and viewing them with :

Code: Select all

echo '<pre>';
var_dump($_GET);
var_dump($_POST);
echo '</pre>';
so now how do I extract the record(s) from the DB (each result is a different table) with the following information.

["paperCategoryId"]=> string(1) "2"
["stockId"]=> string(1) "1"

tia, Will.
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

left join your tables together?

i just did a similar project, maybe you can get a few ideas from it.

http://www.koduleht.net/~andrew/search.php.txt

granted it might not make too much sence to you but it gives the idea of how to choose multiple "where" fields to get one final results across many diffrent tables
facets
Forum Contributor
Posts: 273
Joined: Wed Apr 13, 2005 1:53 am
Location: Detroit

Multi-table searching guides and input

Post by facets »

So does anyone else have any guides on multi-table searching?
Post Reply