I want to be able to dynamically create variable names in a for loop.
For example I have variables from $thing1, $thing2, $thing3 to $thing10.
I want to be able access these variables in a for loop which goes from 1 to 10.
Please help me?? If it's possible, I don't even know if it is...
The variables come from a list of checkbox's from a table in a form, each checkbox represents a record which will be deleted if selected, a selected checkbox VALUE contains the ID of the record which is to be deleted.
The solution to this exact issue is given in Part 6 of my article series, "Building a Database-Driven Web Site using PHP and MySQL" on SitePoint.com. The exact page where this is discussed is here: Managing Jokes (cont'd.)
I've now put a delete all checkbox into the form. The only problem is that If the user selects delete all, then all the separate boxes are not checked. I've tried passing back the query from the function which I have in an include file but it doesn't work. Each time the value is passed back it is not set.
Yes you can check the 'delete all' box separately. Unfortunately I cannot tell what the ID of the record each checkbox holds is, because they themselves would not be checked.
Each checkbox returns the ID value of each record, if it is not checked it returns nothing.
What I need is a way of checking which records were displayed in the remove form, could I maybe add a hidden value to each record in the form??? then I could access the ID value no matter what, in the next page.
Ross, refer again to the way I do it my article. Since you are creating your checkboxes from the database, why not use the same list from the database to process the checkboxes?
I cannot access the list from the database when the remove form is submitted. But I did find a solution. I added a hidden value containing the ID of each record to the form then I use the same process on the hidden values that I use on the checkbox values when delete all is selected.
Bookmarks