Selection problem

From: Date: Sun, 07 Sep 2003 22:43:05 +0000
Subject: Selection problem
Groups: php.db 
Request: Send a blank email to php-db+get-30405@lists.php.net to get a copy of this message
Hi there everyone, I'm having a strange problem, I have a form with 2 fields, 1 is for points (Weightwatcher points) and one is for recipe names. If you select points (IE: 1-3, 3-6,6-9,9 and above) it works perfectly, displays the recipes and allows you to select a new points range from the dropdown. Next to it, on the same form, you can also select by recipe name and ignore the points instead selecting by the recipe name - this works fine, you can select 1, view it and then select another. The problem comes when you select a recipe from the dropdown and view it, then decide you want to select points instead - the points won't work once you have selected a recipe. Can anyone see anything below that is wrong? I am sure it's the if statement, i'm not sure how to handle it as you can select either option to get the result. Any help would really be appreciated, if I haven't confused you all to death :-) Regards Chris <? if ($nameb == ""){ $query = "SELECT * FROM recipes WHERE points $pointsb"; } else { $query = "SELECT * FROM recipes WHERE name = '$nameb'"; }; $sql_result = mysql_query($query,$connection) or die("Couldn't execute query."); while ($row = mysql_fetch_array($sql_result)) { $id = $row["id"]; $name = $row["name"]; $points = $row["points"]; $ingredients = $row["ingredients"]; $instructions = $row["instructions"]; }; ?>

« previous php.db (#30405) next »