0

Hi,

I have a situation that is producing NULL values:

The situation is best explained with this code at this link:

http://www.daniweb.com/web-development/php/threads/227698

Initially, I had a link called "add to list" for each record the display page displayed. I used to hide the row-id in there and pass it onto the next page for processing. Now, with multiple items displayed as rows, one after the other, I am supposed to put the quantity that the user wants to order and check the checkbox next to it. After doing this with several other items, the user click on a link that generates the add action with the arrays for the checkboxes and textboxes being passed through for processing to another page. The thread that I mentioned above explained and put some sample code that I have tried to analyze it and incorporate that code for my situation. Except that, its producing NULL values. I am var_dumping out the values and they all have NULL. The "$row produces the right id value and the records themselves are being displayed, except for the values that I need to get back from the "checkboxes" array and the "textboxes" array.

I might not have understood the code correctly and have attached here. If you could explain the situation and advise me on what I am missing, I would appreciate it. Thanks

$output[] = '<td>'."<input type='text' size='5' maxlength='5' name='Value[{$row['id']}]' value='{$row['value']}'>". '</td>';

In the above code, I am assuming that the name assigned to the textbox is the "Value[{150}]" if the value of the "rowid" is say 150. I am assuming that an array called "Value" with indexes that represent the "row_id" from the db is being put away in memory for later retrieval. The value part of the input is a little confusing. I cannot seem to get my head around that.

$output[] = '<td>'."<input type='checkbox' name='Update[{$row['id']}]' value='Box #{$row['id']}'>".'</td>';

The above code has an "Update" array that has indexes represented by the "row_ids" from the DB. I am trying to get my head around this construct.

The other link specified the following code to retrieve the contents of both Arrays?? at this point as such:

foreach($_POST['Update'] as $_id => $_label) {
    $newValue = $_POST['Value'][$_id];
    $sql = "UPDATE tbl SET `value` = '{$newValue}' WHERE `id` = {$_id}";
    }

A little lost at this point. Any help would be appreciated. Thanks

sb

1
Contributor
1
Reply
2
Views
6 Years
Discussion Span
Last Post by stonybony
0

file index.php:

$output[] = '<td>'."<input type='text' size='5' maxlength='5' name='Value[{$row['id']}]' value='{$row['value']}'>". '</td>';

$output[] = '<td>'."<input type='checkbox' name='Update[{$row['id']}]' value='Box #{$row['id']}'>".'</td>';

item#1 enter quantity, check checkbox
item#2 enter qty, check checkbox 
...
..
...

"Add to list" link at the bottom of the page send this form for processing to "cart.php"
with the link:

http://cart.php?action=add&chk=chkbox_array&qty=qty_array

"cart.php"

get qty array in a local variable
get chkbox array in a local variable
start adding

I have NULL values being filled in for both arrays. Please help. Thanks

sb

Edited by mike_2000_17: Fixed formatting

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.