Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP / MySQL Where clause dilemia

Status
Not open for further replies.

SundancerKid

Programmer
Joined
Oct 13, 2002
Messages
116
Location
US
I need help with the where clause (Which function to Use to evaluate)

The drop down box contains s_item
=PartNumber value asphericallenses.partnumber
=Diameter1 value asphericallenses.diameter1 +/-5%
=Diameter2 value asphericallenses.diameter2 +/-5%

Text Box conatins s_word

$a_s_item = s_Item
$a_s_word = s_word

// Works fine by it's self with asphericallenses.partnumber

Where $a_s_item like '%$a_s_word%'

Results:

// Works fine by it's self with asphericallenses.diameter1 or asphericallenses.diameter2 Searches 5% variance + or -

Where $a_s_item between ((($a_s_word * .05) - $a_s_word) * -1) and (($a_s_word * .05) + $a_s_word)

Results:

I would like a evaluation statement to decide which routine to pass to the WHERE clause. can I use an IF function??? or What do I use???

Am I correct? IF(Evaluate, True, False)

Where if($a_s_item='asphericallenses.partnumber', $a_s_item like '%$a_s_word%', $a_s_item between ((($a_s_word * .05) - $a_s_word) * -1) and (($a_s_word * .05) + $a_s_word))

SQL Routine MYSQL & PHP:

$w_sqlstr = "SELECT asphericallenses.PartNumber, asphericallenses.Diameter1, asphericallenses.Diameter2, asphericallenses.FocalLength, asphericallenses.SphericalRadius, asphericallenses.CenterThickness, asphericallenses.Material FROM asphericallenses WHERE (if($a_s_item='asphericallenses.partnumber', $a_s_item like '%$a_s_word%', $a_s_item between ((($a_s_word * .05) - $a_s_word) * -1) and (($a_s_word * .05) + $a_s_word)))";
 
yoou could try the case when approach (read the docs on how it works) but in my estimation it would be easier to assign a numerical ID to each possible of the product to make searches on numbers instead of text...

ie
productID
productCat
productItemName
productItemDescription

any drop down then contain the productID as a value and the productItemNames as the entry in the box...

Bastien

Any one have a techie job in Toronto, I need to work...being laid off sucks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top