![]() |
Problems filling a table with multiple checkboxes
Here's the problem I'm having. I've a table with products and a list of orders. I need to match up the products to the orders in an orginizational page.
I've created a repeat region and a product image set that uses product images and id's to create a list. This part works just fine and it's part of the submission form. The code looks like this: PHP Code:
The other information is a user ID and an order ID that also work just fine. I've created an insert function that should be working to populate a database table that only has 3 columns other than the primary ID. The Columns are, userID, glryID, and imgID. I want to be able to review the order and check a bunch of images from the generated list and then click the submit button and have a new row generated for each image ID. The problem I'm having is that the insert loop isn't looping and I'm only getting the first digit of any of the information. Here's the code for that: PHP Code:
For example if the user ID is 93 and the image ID is 42 and the page id is 12 the resulting table row is userID 9, imgID 4, and glryID 1. I'm pretty sure the error is in the first line of code for the Insert method. Any help would be appreciated. |
PHP Code:
PHP Code:
BTW It only returns one row because the glryID string of '1' doesn't have a second character to retrieve. |
That explains the first character problem. Now to the other problem. I'm trying to select from dozens of check boxes individual items. Each item will be put in a table, one row per item. It's just like any shopping cart. Retrieve values from an array of items and put them together in an order with a new line in the database for each item.
I've looked at about 20 solutions for submitting data from multiple check boxes and none of them work. Am I going about this all wrong? Retrieving a list of products from a products table, giving each a check box, then expecting that if I select 5 products I'll be able to generate 5 new rows of data in the orders table. For order number 10, product 1 Checked product 2 not checked product 3 not checked product 4 Checked product 5 Checked Insert records inserts these values into the table. order 1 ID, Product 1 ID order 1 ID, Product 4 ID order 1 ID, Product 5 ID Now I can call up order 1 and see all products where order ID = 1 using a repeat region method. If I add one product at a time this works. I need to add a bunch of products with one submit button. Any ideas would help a lot. Thanks |
You create an array of checkboxes by appending square brackets to the end of their name - using the same name. NB only checked items will be posted, the others will just disappear - into Santa's flight path :)
Something like this: Code:
<input type='checkbox' value="Product1" name='cBox[]'/>PHP Code:
|
Thanks for the help. I'm almost there. I'm getting multiple entries but I'm getting a null in the imgID Field. I've tried a bunch of variations but I can't seem to call up the img.id. Probably going blind...
Here's my Code: PHP Code:
|
PHP Code:
PHP Code:
|
Why is the following
PHP Code:
Besides, you've already stored it as a variable $orderID. Once you've created this variable you should refer to it further down, and not keep reverting to the original posted version. |
Thanks for helping me see what I should have seen earlier. I have made this same mistake several times before. It's so easy to define a value and then later call the definition instead of the value.
PHP Code:
The other line was also better placed at the top of the method. I replaced the line PHP Code:
PHP Code:
Thanks for your help. |
Quote:
My advice is to do things like this: PHP Code:
|
That's a good suggestion.. Wish I could mark this issue resolved. The option seems to have disappeared from the original post.
|
Quote:
|
Thanks for the suggestions
|
| All times are GMT +1. The time now is 02:23 PM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.