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 gkittelson 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

Status
Not open for further replies.

SundancerKid

Programmer
Oct 13, 2002
116
US
I need help with the where clause (Which Parameters to Use)

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)))";
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top