RE: [PHP-DB] Creating checkbox list.

2006-02-21 Thread Bastien Koert

I'll skip the sql (figuring you'll have that covered)

while($rows = mysql_fetch_array($result))
{
  $id   = $rows['group_id'] ;
  $name = $rows['group_name'];

  echo input name=\sel_group[]\ type=\checkbox\ 
value=\$id\$nameBR ;

}



Bastien



From: Jeff Broomall [EMAIL PROTECTED]
To: php-db@lists.php.net
Subject: [PHP-DB] Creating checkbox list.
Date: Tue, 21 Feb 2006 20:52:13 -0500

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
--- 
1Group A
2Group B
3Group C
4Group D

I would like to dynamically create a checkbox selection similar to:

input name=sel_group[] type=checkbox value=1Group ABR
input name=sel_group[] type=checkbox value=2Group BBR
input name=sel_group[] type=checkbox value=3Group CBR
input name=sel_group[] type=checkbox value=4Group DBR

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



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



Re: [PHP-DB] Creating checkbox list.

2006-02-21 Thread MIGUEL ANTONIO GUIRAO AGUILAR


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 [EMAIL PROTECTED]
Fecha: Martes, Febrero 21, 2006 7:52 pm
Asunto: [PHP-DB] 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
 --- 
 1Group A
 2Group B
 3Group C
 4Group D
 
 I would like to dynamically create a checkbox selection similar to:
 
 input name=sel_group[] type=checkbox value=1Group ABR
 input name=sel_group[] type=checkbox value=2Group BBR
 input name=sel_group[] type=checkbox value=3Group CBR
 input name=sel_group[] type=checkbox value=4Group DBR
 
 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



Re: [PHP-DB] Creating checkbox list.

2006-02-21 Thread Luis Morales
Hi,

first you need connect to the database y attach on this example a litle
extension class of Pear DB class. I suppose that your case use mysql
database.

this is an example: 

?

require_once db.clas.php

$DB = array ();
$DB['type'] = 'mysql';
$DB['host'] = '10.10.1.7';
$DB['user'] = 'youruser';
$DB['password'] = 'yourpassword';
$DB['dbname'] = 'yourdb';

function myCheck($op){
 global $DB;
 $mdb = new mdb;
 $out = ;
 $q = select * from checkbox_table order by groups_name;
 
 if($db-db_dbArray($DB, $q)){
   for($i=0;$icount($db-_db['data']);$i++){
 $checked = ($db-_db['data'][$i]['groups_id'] == $i) ? checked :
;
 $out .= input name='sel_group[]' type='checkbox'
value='{$db-_db['data'][$i]['groups_id']}'
{$checked}{$db-_db['data'][$i]['groups_name']}BR;
   }
 }
 return $out;
}
?

form name=checkbox method=post action=?= $_SERVER['PHP_SELF']?
ENCTYPE=multipart/form-data
?= myCheck($_REQUEST['sel_group']) ?
/form




On Tue, 2006-02-21 at 20:52 -0500, Jeff Broomall wrote:
 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
  --- 
  1Group A
  2Group B
  3Group C
  4Group D
 
 I would like to dynamically create a checkbox selection similar to:
 
 input name=sel_group[] type=checkbox value=1Group ABR
 input name=sel_group[] type=checkbox value=2Group BBR
 input name=sel_group[] type=checkbox value=3Group CBR
 input name=sel_group[] type=checkbox value=4Group DBR
 
 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 
 
-- 
-
Luis Morales 
Consultor de Tecnologia
Cel: +(58)416-4242091
-
Empieza por hacer lo necesario, luego lo que es posible... y de pronto
estarĂ¡s haciendo lo imposible
-


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