Re: Nested foreach ?
| From: | Stuart Felenstein | Date: | Mon, 18 Oct 2004 07:24:26 +0000 |
| Subject: | Re: Nested foreach ? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-199705@lists.php.net to get a copy of this message | ||
Not working.
> foreach($_SESSION['skills'] as $key => $skill)
> {
> $query = "INSERT INTO table (skill, sky, sku)
> VALUES ('$skill',
>
{$_SESSION['skys'][$key]},{$_SESSION['slus'][$key]})";
> //run query
> }
The foreach is generating an invalid argument.
I'm just going to show again what I have set up:
There are five for each of these:
<input name="skill[]" type="text" id="skill[]"></td>
<select name="sky[]" id="sky[]">
<select name="slu[]" id="slu[]">
Then I post the session variables as:
$_SESSION['skills'] = $_POST['skill'];
$_SESSION['skys'] = $_POST['sky'];
$_SESSION['slus'] = $_POST['slu'];
It looks like the loop above is using the $skills
array to advance through the other arrays ?
Stuart