Page 1 of 1

Searching DB Assistance

Posted: Wed Jun 22, 2005 1:07 am
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

Posted: Wed Jun 22, 2005 6:28 am
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.

Posted: Wed Jun 22, 2005 6:40 am
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

Multi-table searching guides and input

Posted: Wed Jun 22, 2005 11:26 pm
by facets
So does anyone else have any guides on multi-table searching?