Try unset after the if statement
if ($nameb == ""){
$query = "SELECT * FROM recipes WHERE points $pointsb";
} else {
$query = "SELECT * FROM recipes WHERE name = '$nameb'";
$new_nameb = $nameb;
unset($nameb);
}
Gary Every
Sr. UNIX Administrator
Ingram Entertainment
(615) 287-4876
"Pay It Forward"
mailto:[EMAIL PROTECTED]
http://accessingram.com
> -----Original Message-----
> From: Chris Payne [mailto:[EMAIL PROTECTED]
> Sent: Sunday, September 07, 2003 5:43 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] Selection problem
>
>
> 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
>