Re: [PHP] Dynamic Form List - how to change values
tedd wrote: Pat: I would suggest changing to: http://.../chkout.php?imagename=NATURE-1.jpgcount=6continue=Continue+Checkout, $newqty = $_GET['count']; $imagename = $_GET['imagename']; Also, to see what you are actually getting try: echo (br/); echo (pre); echo (GET info:\n); print_r($_GET); echo(/pre); You might also want to consider taking care of undefined variables -- here's a reference: http://www.weberdev.com/get_example-3823.html HTH's tedd Ok, this works for one item, but my shopping cart may have (hopefully) dozens of items in it. How do I refer to each new quantity changes for each new row in the table? I was hoping that by making the qty field a name of the image, I would be able to match the new qty up with the right image quickly, but that won't work, obviously. How can I change multiple items in a list (or all) when the list is dynamically created? My approach may be wrong -- suggestions? Pat: You can add numerous items to the url. I don't remember the total number of characters that's allowed, but it's considerable. if your running Apache the default max length of the url is 8K - this can be upped but you have to recompile Apache. the HTTP spec itself doesn't stipulate a limit to the length... in general though anything over 512 bytes (outside of CMS tools) is discouraged... If you reach the limit, but might consider reducing the number of characters in your variables, such as: NATURE-1.jpg could be n1 where you had a look-up table or you knew what the cryptic code was to make the transformation. Or you could continue on a course like you were with n1=6 where you know that n1 stands for NATURE-1.jpg and the value contained therein is the value for that image. There's lot's of ways to do this. As for it being dynamically created, that shouldn't present a problem either -- just treat the url as a string and add ampersands () between variables and their value pairs. HTH's tedd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dynamic Form List - how to change values
I have a list from a MYSQL database that I am dumping to a screen. I'd like the user to be able to change the quantity on the form for any record on the screen, then post that information back so the user can review it, and I can then update the database. Simple checkout routine. Or so I thought. I have these fields displayed on the screen before the user changes the quantity: $imageqty = $row[cialbum].-.$row[ciset].-.$row[ciimage]; $qty = $row[ciqty]; print td align='center' valign='top'input type='text' name='$imageqty' size='5' value='$qty'/td; I've set the $imageqty variable to hold the initial value from the database. The initial screen works fine. However, when I reprocess the file, how can I retrieve the original value of the field that is named the same as $imageqty? The form outputs something like this: http://.../chkout.php?NATURE-1.jpg=6continue=Continue+Checkout, which does show the $imageqty of NATURE-1.jpg value with the new qty of 6. How can I get the script to pull the value? $imageqty = $row[cialbum].-.$row[ciset].-.$row[ciimage]; $newqty = $_GET[$imageqty]; Retrieves nothing. Thanks for your help. Pat Pat: I would suggest changing to: http://.../chkout.php?imagename=NATURE-1.jpgcount=6continue=Continue+Checkout, $newqty = $_GET['count']; $imagename = $_GET['imagename']; Also, to see what you are actually getting try: echo (br/); echo (pre); echo (GET info:\n); print_r($_GET); echo(/pre); You might also want to consider taking care of undefined variables -- here's a reference: http://www.weberdev.com/get_example-3823.html HTH's tedd -- http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dynamic Form List - how to change values
tedd wrote: I have a list from a MYSQL database that I am dumping to a screen. I'd like the user to be able to change the quantity on the form for any record on the screen, then post that information back so the user can review it, and I can then update the database. Simple checkout routine. Or so I thought. I have these fields displayed on the screen before the user changes the quantity: $imageqty = $row[cialbum].-.$row[ciset].-.$row[ciimage]; $qty = $row[ciqty]; print td align='center' valign='top'input type='text' name='$imageqty' size='5' value='$qty'/td; I've set the $imageqty variable to hold the initial value from the database. The initial screen works fine. However, when I reprocess the file, how can I retrieve the original value of the field that is named the same as $imageqty? The form outputs something like this: http://.../chkout.php?NATURE-1.jpg=6continue=Continue+Checkout, which does show the $imageqty of NATURE-1.jpg value with the new qty of 6. How can I get the script to pull the value? $imageqty = $row[cialbum].-.$row[ciset].-.$row[ciimage]; $newqty = $_GET[$imageqty]; Retrieves nothing. Thanks for your help. Pat Pat: I would suggest changing to: http://.../chkout.php?imagename=NATURE-1.jpgcount=6continue=Continue+Checkout, $newqty = $_GET['count']; $imagename = $_GET['imagename']; Also, to see what you are actually getting try: echo (br/); echo (pre); echo (GET info:\n); print_r($_GET); echo(/pre); You might also want to consider taking care of undefined variables -- here's a reference: http://www.weberdev.com/get_example-3823.html HTH's tedd Ok, this works for one item, but my shopping cart may have (hopefully) dozens of items in it. How do I refer to each new quantity changes for each new row in the table? I was hoping that by making the qty field a name of the image, I would be able to match the new qty up with the right image quickly, but that won't work, obviously. How can I change multiple items in a list (or all) when the list is dynamically created? My approach may be wrong -- suggestions? Pat -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dynamic Form List - how to change values
Pat: I would suggest changing to: http://.../chkout.php?imagename=NATURE-1.jpgcount=6continue=Continue+Checkout, $newqty = $_GET['count']; $imagename = $_GET['imagename']; Also, to see what you are actually getting try: echo (br/); echo (pre); echo (GET info:\n); print_r($_GET); echo(/pre); You might also want to consider taking care of undefined variables -- here's a reference: http://www.weberdev.com/get_example-3823.html HTH's tedd Ok, this works for one item, but my shopping cart may have (hopefully) dozens of items in it. How do I refer to each new quantity changes for each new row in the table? I was hoping that by making the qty field a name of the image, I would be able to match the new qty up with the right image quickly, but that won't work, obviously. How can I change multiple items in a list (or all) when the list is dynamically created? My approach may be wrong -- suggestions? Pat: You can add numerous items to the url. I don't remember the total number of characters that's allowed, but it's considerable. If you reach the limit, but might consider reducing the number of characters in your variables, such as: NATURE-1.jpg could be n1 where you had a look-up table or you knew what the cryptic code was to make the transformation. Or you could continue on a course like you were with n1=6 where you know that n1 stands for NATURE-1.jpg and the value contained therein is the value for that image. There's lot's of ways to do this. As for it being dynamically created, that shouldn't present a problem either -- just treat the url as a string and add ampersands () between variables and their value pairs. HTH's tedd -- http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dynamic Form List - how to change values
Thanks to all who helped. The answer...drumroll arrays for each entry: load routine (partial): print td align='center' valign='top'input type='text' name='imageqty[]' size='5' value='$qty'/td; print input type='hidden' name='hiddenalbum[]' value='.$row[cialbum].'; print input type='hidden' name='hiddenset[]' value='.$row[ciset].'; print input type='hidden' name='hiddenimage[]' value='.$row[ciimage].'; print input type='hidden' name='hiddensize[]' value='.$row[cisize].'; retrieval routine (partial): $cartid = $_COOKIE['PHPSESSID']; $imageqty = $_POST['imageqty']; $qty = $_POST[imageqty]; $album = $_POST[hiddenalbum]; $set = $_POST[hiddenset]; $image = $_POST[hiddenimage]; $size = $_POST[hiddensize]; $n = count($qty); $index = 0; while($index $n) { $newqty = $qty[$index]; $queryupdate = update CartItems set ciqty = '$newqty' where ciid = '$cartid' and cialbum = '$album[$index]' and ciset = '$set[$index]' and ciimage = '$image[$index]' and cisize = '$size[$index]'; querythedatabase($queryupdate);// my routine $index++; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php