RE: [PHP] making a tutorial

From: Date: Fri, 17 Mar 2006 11:15:16 +0000
Subject: RE: [PHP] making a tutorial
Groups: php.general 
Request: Send a blank email to php-general+get-232104@lists.php.net to get a copy of this message
On 17 March 2006 07:39, Gustav Wiberg wrote: > ----- Original Message ----- > From: "John Taylor-Johnston" <jt.johnston@USherbrooke.ca> > To: "PHP-General" <php-general@lists.php.net> > Sent: Friday, March 17, 2006 7:51 AM > Subject: [PHP] making a tutorial > > > > I'm making a tutorial and don't really understand how to do this > > myself :) > > > > <p>Which of the following pets do have at home: > > <br /><input type="checkbox" name="favourite[]" > > value="dog">dog > > <br /><input type="checkbox" name="favourite[]" > > value="cat">cat > > <br /><input type="checkbox" name="favourite[]" > > value="snake">snake > > <br /><input type="checkbox" name="favourite[]" > > value="other">snake > > <br /><input type="checkbox" name="favourite[]" > > value="none">none > > of these </p> > > > > How do I parse favourite[]? I might have 2 or 5, so I need to parse > > ^0] - nMax. It is a checkbox. > > > > I might use favourite[] with mail() or store it in a mysql field. > > > > If mysql, would I store it in a varchar(20) or an enum() and how? > > > > John > > > > > Hi there! > > Do you have to name it as favourite[]? Can't you name it as "just" > favourite (without brackets) You need [] for it to be an array in PHP -- otherwise you only get one value no matter how many are checked. > If you name it as just favourite, at least in Javascript you could > loop through favourite as an array. I don't know if this works in PHP > as well. It's easy enough to treat it as an array in Javascript with the brackets -- you just have to understand the equivalence between objects and arrays. Cheers! Mike --------------------------------------------------------------------- Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Headingley Campus, LEEDS, LS6 3QS, United Kingdom Email: m.ford@leedsmet.ac.uk Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm

« previous php.general (#232104) next »