Re: Forms and While Loop

From: Date: Wed, 01 Nov 2000 23:29:51 +0000
Subject: Re: Forms and While Loop
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-23268@lists.php.net to get a copy of this message
This code sets $CatID = 1 for every instance of the loop. What I am trying to do is modify MyCart (index.php) to produce a drop down list showing the various categories ($Cat). When a category is selected from the list, the form URL is set to include CA=$CatId and the UID, so for Category 1; $CatID=1, Category 2; $CatID=2, etc. The problem I have is that I can't figure out to get the <form action=.....> to pick up the $CatID variable, no matter what I have tried. If I put the <form action=......> inside the loop, I get multiple drop down boxes (no good). I hope this explains my problem a bit better. Wayne ----- Original Message ----- From: "Jason Cox" <jasonc@webpipe.net> To: "Wayne Michel" <wayne@michel.com.au> Cc: <php-general@lists.php.net> Sent: Thursday, November 02, 2000 9:44 AM Subject: RE: [PHP] Forms and While Loop > Of course the $CatID variable doesn't show in the action line. According to > your code, it is even defined until later in the script. I don't know > exactly what you're trying to do but this might work for you: > > > $row = mysql_fetch_row($result); > $CatID=$row[1]; > echo "<p><form method=\"post\" > action=\"$Relative/items.php?CA=$CatID&amp;UID=$UID\"><select > name=\"CatList\" size=\"1\">"; > do > { > $Cat=$row[0]; > $CatID=$row[1]; > echo "<option value=\"$row[0]\"> $row[0] </option>"; > } while ($row = mysql_fetch_row($result)) > echo "</select><input type=\"submit\" name=\"Submit\" > value=\"Go to > Category\"></p></form>"; > > Jason > > > > -----Original Message----- > > From: Wayne Michel [mailto:wayne@michel.com.au] > > Sent: Wednesday, November 01, 2000 3:37 PM > > To: PHP List > > Subject: [PHP] Forms and While Loop > > > > > > I am trying to produce a drop-down list. Relevant (I think) code follows: > > > > echo "<p><form method=\"post\" > > action=\"$Relative/items.php?CA=$CatID&amp;UID=$UID\"><select > > name=\"CatList\" size=\"1\">"; > > while ($row = mysql_fetch_row($result)) > > { > > $Cat=$row[0]; > > $CatID=$row[1]; > > echo "<option value=\"$row[0]\"> $row[0] </option>"; > > } > > echo "</select><input type=\"submit\" name=\"Submit\" > > value=\"Go to > > Category\"></p></form>"; > > > > It all works well except the variable $Cat is not showing in the action > > line. I have to get it to work with various layouts, but I am at an > > impasse. As a new PHP coder, I try to think it through, but this > > time I am > > stuck. > > > > Can anyone show me how to get the variable $Cat, inside the loop, > > to appear > > in the action line. > > > > Thanks > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > > For additional commands, e-mail: php-general-help@lists.php.net > > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > > > > > > _______________________________________________________ > Site Design, Hosting, and E-Commerce at www.webpipe.net

« previous php.general (#23268) next »