You are here: Re: PHP/MySQL and Checkboxes « All PHP « IT news, forums, messages
Re: PHP/MySQL and Checkboxes

Posted by Martin Jay on 05/27/06 00:24

In message <1148669676.491946.94730@g10g2000cwb.googlegroups.com>,
sloane.irwin@gmail.com writes
>I'm sorry but this is all brand new to me. My boss wanted me to use
>INSERT INTO SET using the VALUES keyword, and everything works fine
>except for the checkboxes. Can checkboxes not be used unless with an
>array?

Yes they can. I think the problem with your code is that if the drive1
box isn't ticked on the web page, $_REQUEST['drive1'] won't exist. So,
this portion of the code I posted:

isset($_REQUEST['drive1'])) ? $_REQUEST['drive1'] : "";

returns either the value of $_REQUEST['drive1'] if it exists, or ""
(empty) if it doesn't.

>Also, I don't just want certain checkboxes checked in the view/edit
>page, I want the ones that correspond to the row in the db checked
>because each entry will be different.

An example of how to do this would be to change:

<input type="checkbox" name="drive1" value="yes">

to this:

<input type="checkbox" name="drive1" value="yes" <?php
isset($_REQUEST['drive1'] echo "checked"; ?>>

So that if $_REQUEST['drive1'] exists the word "checked" becomes part of
the <INPUT> element and the box is checked.
--
Martin Jay
Phone/SMS: +44 7740 191877
Fax: +44 870 915 2124

 

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

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