Hai all,
I managed to add dynamic checkboxes(ie., if i add data in database checkbox will automatically generated in another form
Coding Create table trole(id,role,i sadmin)
=======
<?php
$sql="select id,role from trole where isadmin='0'";
$result=mysql_q uery($sql);
$count=mysql_nu m_rows($result) ;
$role='';
$ID='';
$role1='';
$i = 0;
if ($count < 1) {
echo "There are No Records";
}
else
{
while ($count > $i) {
$ID = mysql_result($r esult,$i,'id');
$role = mysql_result($r esult,$i,'role' );
//$NA= mysql_result($p Result,$i,"Your Name");
//print out checkboxes and escape quotes
$_SESSION['ID']=$ID;
$_SESSION['role']=$role;
echo "<input type=\"checkbox \" name=\"role[]\" value=\"$ID\">" ;
echo($role);
echo($ID);
$i++;
}
}
Example outputs
===============
2(id)student(ro le), 3(id)faculty(ro le), 4(id)others
Now my problem is if i select id 2 and 4 it should add 2&4 in database but i',m getting default value 4 for every data (ex: if i select 2&3 it should add 2&3 but i'm getting as 4 for every one.)
Please help, Apologise if my english is not good.
Thanks
I managed to add dynamic checkboxes(ie., if i add data in database checkbox will automatically generated in another form
Coding Create table trole(id,role,i sadmin)
=======
<?php
$sql="select id,role from trole where isadmin='0'";
$result=mysql_q uery($sql);
$count=mysql_nu m_rows($result) ;
$role='';
$ID='';
$role1='';
$i = 0;
if ($count < 1) {
echo "There are No Records";
}
else
{
while ($count > $i) {
$ID = mysql_result($r esult,$i,'id');
$role = mysql_result($r esult,$i,'role' );
//$NA= mysql_result($p Result,$i,"Your Name");
//print out checkboxes and escape quotes
$_SESSION['ID']=$ID;
$_SESSION['role']=$role;
echo "<input type=\"checkbox \" name=\"role[]\" value=\"$ID\">" ;
echo($role);
echo($ID);
$i++;
}
}
Example outputs
===============
2(id)student(ro le), 3(id)faculty(ro le), 4(id)others
Now my problem is if i select id 2 and 4 it should add 2&4 in database but i',m getting default value 4 for every data (ex: if i select 2&3 it should add 2&3 but i'm getting as 4 for every one.)
Please help, Apologise if my english is not good.
Thanks
Comment