OK. Stumped once again. This function is now properly generating and displaying the form as I intend it to. The only problem is that the optional text and button at the end of the function is actually displaying above the choices provided in the while loop from the database. Please let me know what you think. function CheckboxList($query, $CheckboxText) { $cnt = 1; $result1 = mysql_query($query); echo "<form name=\"form1\" method=\"post\" action=\"test_display.php\">"; echo "<table border=\"0\" align=\"center\">"; while ($list = mysql_fetch_assoc($result1)) { $sys = split('-', $list['id-sys']); if ($cnt == 1) { $cnt = 2; echo "<tr><td width=\"161\"><input name=\"system[]\" type=\"checkbox\" value=\"$sys[1]\">"; echo $sys[1]."</td>"; } elseif ($cnt == 2) { $cnt = 3; echo "<td width=\"161\"><input name=\"system[]\" type=\"checkbox\" value=\"$sys[1]\">"; echo $sys[1]."</td>"; } elseif ($cnt == 3) { $cnt = 4; echo "<td width=\"161\"><input name=\"system[]\" type=\"checkbox\" value=\"$sys[1]\">"; echo $sys[1]."</td>"; } elseif ($cnt == 4) { $cnt = 1; echo "<td width=\"161\"><input name=\"system[]\" type=\"checkbox\" value=\"$sys[1]\">"; echo $sys[1]."</td></tr>"; } } if ($CheckboxText) { echo "<p align=\"center\"><font size=\"4\">$CheckboxText</font></p>"; } echo "<div align=\"center\"><input type=\"submit\" name=\"Submit\" value=\"Submit\"></div></form>"; } One other question while I am at it... I am wanting to provide a button that selects all of the checkboxes automatically and refreshes the page. You know, a select all button. I know nothing of Javascript, but this is what should do this, correct? Once again, any and all help is most appreciated. -----Original Message----- From: Mark [mailto:mark_weinstock@yahoo.com] Sent: Friday, December 06, 2002 1:58 PM To: 'php-db@lists.php.net' Subject: Re: Function questions... $sys is an array, so echoing $sys will cause problems. Are you trying to get a 4xN table of values and checkboxes? There's got to be an easier way... --- "NIPP, SCOTT V (SBCSI)" <sn4265@sbc.com> wrote: > I am trying to convert something that I have working in a PHP > script > to be a function in a library type of file. The code contained in > the > function works fine in another script, but I am currently getting > no output > from the function. I have a question about the nature of functions > that may > help clear up my problems. > > Do 'echo' commands within functions actually work to directly > display information? I have only used functions up to this point > that use > the 'return' command to pass a variable back to the script that > called the > function. I am pretty confused on how to actually use a function > that > formats data to be displayed. This is my primary source of > confusion. > > Below is the function that is giving me trouble: > > function CheckboxList($query) { > $result1 = mysql_query($query); > do { > $sys = split('-', $list['id-sys']); > if ($cnt == 1) { > $cnt = 2; > echo "<tr><td width=\"161\"><input name=\"system[]\" > type=\"checkbox\" > value=\"$sys\">"; > echo $sys."</td>"; > } elseif ($cnt == 2) { > $cnt = 3; > echo "<tr><td width=\"161\"><input name=\"system[]\" > type=\"checkbox\" > value=\"$sys\">"; > echo $sys."</td>"; > } elseif ($cnt == 3) { > $cnt = 4; > echo "<tr><td width=\"161\"><input name=\"system[]\" > type=\"checkbox\" > value=\"$sys\">"; > echo $sys."</td>"; > } elseif ($cnt == 4) { > $cnt = 1; > echo "<tr><td width=\"161\"><input name=\"system[]\" > type=\"checkbox\" > value=\"$sys\">"; > echo $sys."</td></tr>"; > } > } while ($list = mysql_fetch_assoc($result1)); > } > > Here is also the way I am calling this function: > <snip...> > $query = "SELECT * FROM accounts WHERE > verifyurl='$safe_verify_string'"; > <snip...> > CheckboxList($query); > <snip...> > > Is there something wrong with the way in which I am calling this > function? Thanks in advance for all the help. > > > Scott Nipp > Phone: (214) 858-1289 > E-mail: sn4265@sbc.com > Web: http:\\ldsa.sbcld.sbc.com > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > ===== Mark Weinstock mark_weinstock@yahoo.com *************************************** You can't demand something as a "right" unless you are willing to fight to death to defend everyone else's right to the same thing. -Stolen from the now-defunct Randy's Random mailing list. *************************************** __________________________________________________ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php