RE: [PHP] what am I doing wrong? - closer!

From: Date: Fri, 02 May 2003 19:41:00 +0000
Subject: RE: [PHP] what am I doing wrong? - closer!
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-146187@lists.php.net to get a copy of this message
Ok, here is what I have now, and it is very close: <?$query = "SELECT * FROM list_serv_t WHERE retired_flag is NULL OR retired_flag = 0 ORDER BY list_serv_name"; $search_results = mysql_query($query) or die("Select Failed!"); ?> <?while ($search_result = mysql_fetch_array($search_results)) {?> <INPUT TYPE="CHECKBOX" NAME="list_serv[]" VALUE="<?echo $search_result['list_serv_cd']; ?>"> <? echo $search_result['list_serv_name'] ?> - <? echo $search_result['list_serv_cd'] ?><BR> <?} foreach( $_POST['list_serv'] as $list_serv_cd => $quantity) { $quantity *= 1; // make it numeric if($quantity) { // if one exists echo $list_serv_cd; } }?> I have printed the list_serv_cd beside the name so I can compare them to what the foreach prints out. Unfortuantely, they don't match. Here is what is displayed in HTML: Bursar - 1 Cards on Campus - 3 SLRC - 2 Treasury - 5 0123 So, it looks like I am printing out the loop count. How can I print out the value? Thanks!!! On Fri, 2 May 2003, Dan Joseph wrote: > Hi, > > > > > <?while ($search_result = > > > mysql_fetch_array($search_results)) {?> > > > > <INPUT > > > > TYPE="checkbox" > > > > NAME="list_serv[<? echo > > > > $search_result['list_serv_cd']; ?>]" > > > > SIZE="20" > > > > MAXLENGTH="50" > > > > VALUE="1"><? echo > > > > $search_result['list_serv_name'] ?> <BR> > > > > <? > > It kind of appears that you're making an array type name value in the html. > list_serv[something] instad of just list_serv. > > I would set NAME="list_serv" and VALUE="<?echo > $search_result['list_serv_cd']; ?>" > > I think that will do ths trick. Right now it doesn't think > $_POST['list_serv'] is an array, which it probably isn't from seeing that. > > -Dan Joseph > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > >

« previous php.general (#146187) next »