Re: Creating checkbox list.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




OK, let's see:
First, do the connection to your DB
$query= "select * from groups"; // get the data from your grous table
$ri=mysql_query($query, $li); // execute the query agains your table
while ($data=mysql_fetch_row($ri)) { // get the row in turn, $data is the array that holds your group data
  // the following line prints the checkboxes along with it's values and description
  echo("<input name='sel_group[]' type='checkbox' value=".$data[0].">".$data[1]."<BR>");
}

Miguel


----- Mensaje original -----
De: Jeff Broomall <news@xxxxxxxxxxx>
Fecha: Martes, Febrero 21, 2006 7:52 pm
Asunto:  Creating checkbox list.

> Good evening.
> 
> I'm sure this is something easy so I'm hoping you can simply steer 
> me to a 
> good source.
> 
> I simply need to create a Checkbox list using data from my "groups" 
> table.
> I have a table with two fields:
> 1)  groups_id
> 2)  groups_name
> 
> The data contained is simple:
> 
> groups_id groups_name
> ----------- ----------------
>     1    Group A
>     2    Group B
>     3    Group C
>     4    Group D
> 
> I would like to dynamically create a checkbox selection similar to:
> 
> <input name="sel_group[]" type="checkbox" value="1">Group A<BR>
> <input name="sel_group[]" type="checkbox" value="2">Group B<BR>
> <input name="sel_group[]" type="checkbox" value="3">Group C<BR>
> <input name="sel_group[]" type="checkbox" value="4">Group D<BR>
> 
> So I need a script that'll take this information from the groups table
> and create the above.  Can you help?
> 
> As I look at this, I believe I'm going to need to create an array 
> for my 
> final "report."  So I just added the [] after sel_group.
> 
> Thanks.
> 
> Ward 
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

Este mensaje es exclusivamente para el uso de la persona o entidad a quien esta dirigido; contiene informacion estrictamente confidencial y legalmente protegida, cuya divulgacion es sancionada por la ley. Si el lector de este mensaje no es a quien esta dirigido, ni se trata del empleado o agente responsable de esta informacion, se le notifica por medio del presente, que su reproduccion y distribucion, esta estrictamente prohibida. Si Usted recibio este comunicado por error, favor de notificarlo inmediatamente al remitente y destruir el mensaje. Todas las opiniones contenidas en este mail son propias del autor del mensaje y no necesariamente coinciden con las de Radiomovil Dipsa, S.A. de C.V. o alguna de sus empresas controladas, controladoras, afiliadas y subsidiarias. Este mensaje intencionalmente no contiene acentos.

This message is for the sole use of the person or entity to whom it is being sent.  Therefore, it contains strictly confidential and legally protected material whose disclosure is subject to penalty by law.  If the person reading this message is not the one to whom it is being sent and/or is not an employee or the responsible agent for this information, this person is herein notified that any unauthorized dissemination, distribution or copying of the materials included in this facsimile is strictly prohibited.  If you received this document by mistake please notify  immediately to the subscriber and destroy the message. Any opinions contained in this e-mail are those of the author of the message and do not necessarily coincide with those of Radiomovil Dipsa, S.A. de C.V. or any of its control, controlled, affiliates and subsidiaries companies. No part of this message or attachments may be used or reproduced in any manner whatsoever.

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux