RE: [PHP] Validation problem with array.
| From: | Stuart Felenstein | Date: | Thu, 21 Oct 2004 09:21:12 +0000 |
| Subject: | RE: [PHP] Validation problem with array. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-199960@lists.php.net to get a copy of this message | ||
See below:
--- Graham Cossey <graham@cossey.plus.com> wrote:
> Also, this line :
> foreach($_SESSION['skills'] as $key => $skill)
> could read
> foreach($skills as $key => $skill)
> as you have the line:
> $skills = $_SESSION['skills'];
> Same for skys and slus.
> Graham
Graham,
I've read this over and over and I must be dense
because I"m not totally comprehending it.
Let me show you how I set it all up. Remember it's a
multi page form:
So the form elements are: skills[], skys[], slus[]
Then on the next page I have to still pass the session
variables, and so:
$_SESSION['skills'] = $_POST['skill'];
$_SESSION['skys'] = $_POST['sky'];
$_SESSION['slus'] = $_POST['slu'];
Now the transcation script:
$skills = $_SESSION['skills'];
$skys = $_SESSION['skys'];
$slus = $_SESSION['slus'];
foreach($_SESSION['skills'] as $key => $skill)
{
$query = "INSERT INTO LurkProfiles_Skicerts
(SkicertID, ProfileID, SkilCerts, NumYear, Lused)
VALUES (null, $LID, '$skill',
{$_SESSION['skys'][$key]},{$_SESSION['slus'][$key]})";
//$result = mysql_query($query);
$res6 = run_query($query);
echo $query;
}
I understand that in the insert statement I need not
repeat $_SESSION.
The rest though is fuzzy.
It was working, now I'm getting some really odd
behaviour, in that, unless i fill in every field in
the form, I get a mysql syntax error.
Stuart