RE: Validation problem with array.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



My problem is not related to the insert or iteration.
It's related to the validaton of those elements:
skill[]
skill[]
etc.

Clearer ?

Stuart
--- Graham Cossey <graham@xxxxxxxxxxxxxxx> wrote:

> Not sure I really know where you have the problem,
> but I am assuming you are
> trying to construct the INSERT statement within your
> foreach loop.
> 
> If so, why use $_POST["skill[]"] when you have
> $skill which is that current
> element being iterated?
> Did you read the foreach doc?
>
http://uk2.php.net/manual/en/control-structures.foreach.php
> 
> HTH
> Graham
> 
> 
> > -----Original Message-----
> > From: Stuart Felenstein
> [mailto:stuart4m@xxxxxxxxx]
> > Sent: 20 October 2004 13:35
> > To: php-general@xxxxxxxxxxxxx
> > Subject:  Validation problem with array.
> >
> >
> > After some back and forth posts here I had finally
> > thought my array issue was over, but!
> >
> > To review I have 30 form elements on a page
> > 10 are skill[]
> > 10 are sky[]
> > 10 are slu[]
> >
> > I pass them as session variables
> >
> > $_SESSION['skills'] = $_POST['skill'];
> > $_SESSION['skys'] = $_POST['sky'];
> > $_SESSION['slus'] = $_POST['slu'];
> >
> > Then when everyting is passed into a database
> > transaction:
> >
> > $skills = $_SESSION['skills'];
> > $skys = $_SESSION['skys'];
> > $slus = $_SESSION['slus'];
> >
> > foreach($_SESSION['skills'] as $key => $skill)
> > {
> > $query = "INSERT INTO Profiles_skills (ProfileID,
> > SkilCerts, NumYear, Lused)
> > VALUES ($LID, '$skill',
> >
>
{$_SESSION['skys'][$key]},{$_SESSION['slus'][$key]})";
> > //$result = mysql_query($query);
> >
> > Here is the problem:
> >
> > Using
> > (((isset($_POST["skill[]"]))?$_POST["skill[]"]:"")
> .
> > "",true,true,true,true,"",false,1);
> >
> > I can't seem to differentiate between the the
> elements
> > because they are all labeled skill[]
> > So basically validation isn't doing anything .
> >
> > I'm thinking of finding a better way to validate ,
> or
> > if i change the elements to skill[1], skill[2] ,
> what
> > would that do to my iteration loop ?
> >
> > Thank you,
> > Stuart
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit:
> http://www.php.net/unsub.php
> >
> >
> 
> 
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux