PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
This problem involves selecting multiple orders using checkboxes next to each item on a list of customer names (which was created from a MySQL query) so that the items selected can be moved to an "archived orders" table.
For simplicity's sake, let's say the list is of ten customer names.
My query results give me a page with a list of orders that have come in today, with a checkbox to select the orders I want to process and then archive.
and PHP should make an array called $_REQUEST['checkbox'] which is a numerically indexed array, you get them back in the same order they were on the page
Well, this is a new one for me, so I'm hoping I can find a tutorial or get enough info here to be able to write enough code to start working with the array that's created by my selections.
I don't know how to write the code that interprets the "$_REQUEST['checkbox'] " array once I get it...
Maybe what would help most is to know how to POST the selected items (array) to the next page using a form call and submit button....
<input type="checkbox" name="customerid[]" value = "<?php $customerid ?>"/>
Remember [] in name field. This makes customerid as an array which can hold different customer id values.When form is submitted through post or get method this values is passed as an array in the php file.You can always use this value in the same way you use an array. You can get this value in the simar way you get other values in php.Like this way
Now customerid_array variable will hold all the values passed from form as an array.
But if you forgot to use [] in name field this will led php to understand it as a single variable,which will store the only one customerid value. So when you submit the form it will pass only one last customerid value in the php script.
Seems great... but the number of checkboxes changes based on how many rows are in the 'orders' table. Once the orders have been shipped, they're moved out of that table into another ('archived'), so one morning there might be ten new orders, the next day there could be seven...
Maybe I'm missing something...
thanks.
mc
Seems great... but the number of checkboxes changes based on how many rows are in the 'orders' table.
mc, If I understand correctly what you want:
You can combine jcart's loop to retreive and show the necessary checkboxes with the last example Jenk gave. Then everything is dynamic. The amount of checkboxes shown depends on your db query and the amount of POST values received depends on the amount of checkboxes clicked.