Help - almost got it

From: Date: Fri, 29 Sep 2000 03:59:26 +0000
Subject: Help - almost got it
Groups: php.db 
Request: Send a blank email to php-db+get-3163@lists.php.net to get a copy of this message
Well, I struggled and almost have it figured out, but I have a problem with repeating data: This is a part of the output...it should be that each checkbox only appears once (and as you can notice, the CHECKED is working!!) <INPUT TYPE=checkbox NAME=preq[] VALUE="100" CHECKED>Connecting with WebTV<BR> <INPUT TYPE=checkbox NAME=preq[] VALUE="100">Connecting with WebTV<BR> <INPUT TYPE=checkbox NAME=preq[] VALUE="100">Connecting with WebTV<BR> <INPUT TYPE=checkbox NAME=preq[] VALUE="101">Reading Email<BR> <INPUT TYPE=checkbox NAME=preq[] VALUE="101">Reading Email<BR> <INPUT TYPE=checkbox NAME=preq[] VALUE="101">Reading Email<BR> <INPUT TYPE=checkbox NAME=preq[] VALUE="102">Addressing Email<BR> <INPUT TYPE=checkbox NAME=preq[] VALUE="102" CHECKED>Addressing Email<BR> <INPUT TYPE=checkbox NAME=preq[] VALUE="102">Addressing Email<BR> <INPUT TYPE=checkbox NAME=preq[] VALUE="103">Sending Web Page to other users<BR> <INPUT TYPE=checkbox NAME=preq[] VALUE="103">Sending Web Page to other users<BR> <INPUT TYPE=checkbox NAME=preq[] VALUE="103">Sending Web Page to other users<BR> This is the code that is giving me this problem: <? $prq = db_query(" SELECT preq_id, prereq FROM preqs ORDER BY preq_id ASC "); If ($prq) { while ($allprq = db_fetch_array($prq)) { /* get all prerequisites */ $lsnprq = db_query(" SELECT preq_id FROM lesson_preq WHERE l_id = $id "); if ($lsnprq) { while ($lessonprq = db_fetch_array($lsnprq)) { /* get lesson prerequisites */ $checked = ''; //clear var if ($allprq['preq_id'] == $lessonprq['preq_id']) { /* if the preq has a match in lesson_preq, set the value */ $checked = ' CHECKED'; } //prints all of them correctly but repeats ea preq # times for checked preqs echo ("<INPUT TYPE=checkbox NAME=preq[] VALUE=\"".$allprq['preq_id']."\"".$checked.">".$allprq['prereq']."<BR>\n"); } } } } ?> Can anyone see the silly oversight or mistake I am making? Opinions much appreciated! Luis --------------------------------------------- This message was sent using Mecha WebMail.

« previous php.db (#3163) next »