Re: Re: HTML_quickform setdefaults question
| From: | rav k | Date: | Sun, 10 Dec 2006 21:43:15 +0000 |
| Subject: | Re: Re: HTML_quickform setdefaults question | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-26069@lists.php.net to get a copy of this message | ||
Excellent,
this is what I ended up with:
$statement=$mdb2->prepare('SELECT Skillid FROM Userskills WHERE Userid = ?', array('integer'), array('integer'));
$result=$statement->execute($id['userid']);
$statement->free();
$checked = $result->fetchAll(MDB2_FETCHMODE_ASSOC);
//$checked = array();
foreach ($checked as $s) {
$checked2['skills[' . $s['skillid'] . ']'] = true;
}
$form->setDefaults($checked2);
So in the above example I'm getting the Skillid fields for my Users id and then that goes into the $checked array.
Each of my advcheckboxes is called skills[number] and 'number' is what is saved in the $checkbox array. So the next thing is making a new array of 'skills' and adding 'number' on. Then each of these is set to TRUE to make the box checked.
Not sure if that'll make sure to others - buts that how I did it. Thanks Mark!!
www.bitesoftware.com - software for a better lifestyle
From: Mark Wiesemann <wiesemann@php.net> To: pear-general@lists.php.net Subject: Re: [PEAR] Re: HTML_quickform setdefaults question Date: Sun, 10 Dec 2006 22:29:19 +0100 MIME-Version: 1.0 Received: from lists.php.net ([216.92.131.4]) by bay0-mc7-f8.bay0.hotmail.com with Microsoft SMTPSVC(6.0.3790.2444); Sun, 10 Dec 2006 13:31:21 -0800 Received: from [216.92.131.4] ([216.92.131.4:11525] helo=lists.php.net)by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTPid 4D/10-00543-8AC7C754 for <rav220@hotmail.com>; Sun, 10 Dec 2006 16:31:20 -0500 Received: (qmail 41989 invoked by uid 1010); 10 Dec 2006 21:30:27 -0000 Received: (qmail 41981 invoked by uid 1010); 10 Dec 2006 21:30:27 -0000 X-Message-Info: LsUYwwHHNt14nJ/M3d/msh5Yw7drq120GSjn8PmyCyU= Return-Path: <pear-general-return-26068-rav220=hotmail.com@lists.php.net> X-Host-Fingerprint: 216.92.131.4 lists.php.net Mailing-List: contact pear-general-help@lists.php.net; run by ezmlm Precedence: bulk list-help: <mailto:pear-general-help@lists.php.net> list-unsubscribe: <mailto:pear-general-unsubscribe@lists.php.net> list-post: <mailto:pear-general@lists.php.net> Delivered-To: mailing list pear-general@lists.php.net Delivered-To: ezmlm-scan-pear-general@lists.php.net Delivered-To: ezmlm-pear-general@lists.php.net X-Host-Fingerprint: 212.117.93.247 clx-ac2-247-3.westend.com User-Agent: 40tude_Dialog/2.0.15.1de (92243116.349.251) References: <1grx8hunpgffs.k73su90rkvyq.dlg@40tude.net> <BAY108-F288BCA2574137B1AD1E8399AD10@phx.gbl> X-Posted-By: 212.117.93.247 X-OriginalArrivalTime: 10 Dec 2006 21:31:21.0372 (UTC) FILETIME=[89189DC0:01C71CA2] rav k wrote: Hmm not working quite right: My $checked array is like this: array(4) { [0]=> array(1) { ["skillid"]=> int(2) } [1]=> array(1) { ["skillid"]=> int(3) } [2]=> array(1) { ["skillid"]=> int(6) } So 2, 3, 6 means that skills[2], skills[3] and skills[6] should be checked. I did this: foreach ($checked as $s) { $checked['skills['.$s.']'] =1; } [...] Okay, that's not a PEAR question anymore (it's a PHP question), but this should work: $checked['skills[' . $s['skillid'] . ']'] = 1; Regards, Mark -- PEAR General Mailing List (http://pear.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php_________________________________________________________________ Find Singles In Your Area Now With Match.com! msnuk.match.com