Re: Variable conversion problem

From: Date: Fri, 21 Sep 2001 13:24:08 +0000
Subject: Re: Variable conversion problem
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-68127@lists.php.net to get a copy of this message
On Friday 21 September 2001 01:45, Neil Silvester wrote: > Another PHP problem has kept me up all night, scouring through my database > books and trying everything I could think of. I am still new to the MySQL > and PHP field, but never the lass I will not give up. > $cat is a variable that is passed to the query from the previous page. The > SELECT statement works faultlessly, except for the point at which no choice > is made from the drop down on the page prior to this one. I have set a > value > > of "x" to the drop down for a non selection, but am having problems > converting that "x" value to a "%" value (the MySql wildcard symbol) > withing my SELECT statement. > I am assuming that I will need an IF THEN before the SELECT, but I have > tried several variation to no avail. > > $result = mysql_query("SELECT CompetitorName > FROM competitor, competitorproducts, productcategory > WHERE competitorproducts.CompID=competitor.ID > AND productcategory.ID=\"$cat\" > AND competitorproducts.CatID=productcategory.ID" > ); I'd say there are 2 solutions: 1) Set the default value in the dropdown box to '%'. 2) Just set $cat to whatever you want, when it is 'x' if ($cat == 'x') { $cat = '%'; } Alexander.

« previous php.general (#68127) next »