Selection problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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"];

};

?>

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux