Jump to content

$_POST array


smith.james0

Recommended Posts

I have been playing with the $_POST array. I need to get rid of action and submit from the $key. At the moment i use the following code

echo "<table border=\"1\"><tr><td>First array</td><td>Second array</td><td>Sales</td><td>ID</td><td>Units</td><td>ID</td><td>Extra</td>";
foreach ($_POST as $key => $book) {
if($key == action|| $key == submit)
continue;

echo "<tr><td>$key</td>";
foreach ($book as $key => $value){
echo "<td>Key: $key </td><td> Value: $value</td>";
}
echo "</tr>";
}
echo"</table><p></p>";

It gets rid of the action and submit, BUT it also gets rid of $_POST[0]

1 Key: 0 Value: 2a Key: 1 Value: Key: 2 Value:
2 Key: 0 Value: 3a Key: 1 Value: Key: 2 Value:
3 Key: 0 Value: Key: 1 Value: Key: 2 Value:
4 Key: 0 Value: Key: 1 Value: Key: 2 Value:
5 Key: 0 Value: Key: 1 Value: Key: 2 Value:
6 Key: 0 Value: Key: 1 Value: Key: 2 Value:
7 Key: 0 Value: 8a Key: 1 Value: Key: 2 Value:

On the left hand it should start 0. If i take the following code out

if($key == action|| $key == submit)
continue;

it starts at zero but includes action and submit.

The page is http://xr2.org/fieldnames.php



Can anyone help

Many thanks James
Link to comment
https://forums.phpfreaks.com/topic/30413-_post-array/
Share on other sites

I have changed that bit of code, but it's still not working correctly.
I now have
if($key == "submit")
continue;

if you print the array you get
Array
(
    [0] => Array
        (
            [0] => Line 1
            [1] =>
            [2] =>
        )

    [1] => Array
        (
            [0] => line 2
            [1] =>
            [2] =>
        )

But the first line still gets lost!

First array Second array Sales ID Units ID Extra
1 Key: 0 Value: line 2 Key: 1 Value: Key: 2 Value:

Many thanks James
Link to comment
https://forums.phpfreaks.com/topic/30413-_post-array/#findComment-140297
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.