Jump to content

Trying to make a complex search engine for an online shop


c_shelswell

Recommended Posts

I'm trying to make a search page for a shop to enable the owner of the shop to search for email address over a number of tables. I'm just getting really stuck and starting to realise the way i'm doing it is going to result in so many different possibilities or mysql queries.

 

If got (so far) 3 select boxes with a number of the same option in each

 

<option value='0' selected='selected'></option>
<option value='purchBtwn'>PURCHASED BETWEEN</option>
<option value='notPurchBtwn'>NOT PURCHASED BETWEEN</option>
<option value='purchPend'>PURCHASES PENDING</option>
<option value='country'>COUNTRY</option>
<option value='timezone'>TIMEZONE</option>
<option value='ppemail'>PAYPAL EMAIL</option>
<option value='confEmail'>CONFIRMED EMAIL ADDRESSES</option> 

 

depending on what the user presses another box will appear asking for further info. There's then an 'AND' or 'OR' choice and the same selections appear again. This is obviously going to cause an awful lot of different ways to search and that's just using 3 of the above select boxes.

 

Is the only way to do this to get PHP asking a whole load of 'IF' questions (like the below for first select box) or is there a more elegant way to do this with PHP? Even if anyone knows some online tutorials that might help me here that'd be great.

 


//$sc == $_POST['variables']

if (($sc['srch1'] == "purchBtwn") || ($sc['srch1'] == "notPurchBtwn"))
       {
	$tableOne = "purchases";
	$sDateOne = date_rev(str_replace($replaceSlash, "-", $sc['startDate1']));
	$eDateOne = date_rev(str_replace($replaceSlash, "-", $sc['endDate1']));
	$x = 1;
}
elseif ($sc['srch1'] == "purchPend")
{
	$tableOne = "purchases_pending";
	$sDateOne = date_rev(str_replace($replaceSlash, "-", $sc['startDate1']));
	$eDateOne = date_rev(str_replace($replaceSlash, "-", $sc['endDate1']));
	$x = 1;
}
elseif ($sc['srch1'] == "timezone")
{
	$tableOne = "bill_address";
}
elseif ($sc['srch1'] == "country")
{
	$tableOne = "bill_address";
}
elseif ($sc['srch1'] == "ppemail")
{
	$tableOne = "pp_email";
}
elseif ($sc['srch1'] == "confEmail")
{
	$tableOne = "reg_users";
}

 

Many thanks

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.