You are here: Re: [PHP] Getting checkboxes as array « PHP « IT news, forums, messages
Re: [PHP] Getting checkboxes as array

Posted by jack jackson on 10/20/70 11:18

Thank you Sebastian! Saved me some hell there!!

On 6/9/05, Sebastian <sebastian@broadbandgaming.net> wrote:
> Don't forget to mention that even if you don't select a checkbox it will
> still add a empty record to the db.. i know for sure the foreach loop
> will add a record even if a box is not check, so you have to check its
> actually set before you start inserting.
>
> Richard Davey wrote:
>
> >Hello jack,
> >
> >Friday, June 10, 2005, 2:16:06 AM, you wrote:
> >
> >jj> $query = "INSERT INTO media_art (media_art_id,art_id, media_id)
> >jj> VALUES ('','" . $art_id . "','" . $media_types[2]. "')";
> >
> >jj> repeat as many or few times as possible to account for the number of
> >jj> checked boxes, such as
> >
> >One way:
> >
> >for ($i = 0; $i < count($media_types); $++)
> >{
> > $query = "INSERT INTO media_art (media_art_id,art_id, media_id)
> > VALUES ('','$art_id','{$media_types[$i]}')";
> > // perform query here
> >}
> >
> >Another:
> >
> >foreach ($media_types as $type)
> >{
> > $query = "INSERT INTO media_art (media_art_id,art_id, media_id)
> > VALUES ('','$art_id','$type')";
> > // perform query here
> >}
> >
> >Best regards,
> >
> >Richard Davey
> >
> >
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация