Jump to content

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

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.