Check Box Modify
Posted: Wed Dec 22, 2004 9:29 am
Happy Holidays All.
I am having a hard time with my modify script using checkboxs. What I am trying to do is have checkboxs checked for the services the user already has, and list the rest of the unchecked boxes so they can be checked and unchecked if needed. Now I can get it display just fine with the already checked boxes, only problem is it repeats the remaining list as many times as the services that are checked. I know that my while and do loop is probably screwed up somewhere.. But after looking at it for a while.. I can not figure out where...
Any Help would be greatly appreciated!
Now The Code :
I am having a hard time with my modify script using checkboxs. What I am trying to do is have checkboxs checked for the services the user already has, and list the rest of the unchecked boxes so they can be checked and unchecked if needed. Now I can get it display just fine with the already checked boxes, only problem is it repeats the remaining list as many times as the services that are checked. I know that my while and do loop is probably screwed up somewhere.. But after looking at it for a while.. I can not figure out where...
Any Help would be greatly appreciated!
Now The Code :
Code: Select all
<?php
$sql10=mysql_query("select techid,serviceid from cli_mapping where cid=$cid order by serviceid asc");
while ($arr=mysql_fetch_assoc($sql10)){
$sql1=mysql_query("select sid,sname from services order by sid asc");
if ($row1=mysql_fetch_assoc($sql1)){
do{
if ($arr[serviceid] == $row1[sid]){
$selectedtext = " checked";
print "if print :$arr[serviceid] / $row1[sid]";
} else {
print "else : $arr[serviceid] / $row1[sid]";
$selectedtext = "";
}
?>
<tr><td>
<input name=service[] type=checkbox class=textinput id=service value=<?print $row1[sid];?><?
print "$selectedtext";?>><?print $row1[sname];?></td>
<td><select name=tech[] class=textinput><option value=0>SELECT TECH</option>
<?$sql=mysql_query("select uid,fname from users where status='1' and uid !='1'");
while ($row=mysql_fetch_row($sql)){
print "<option value=$row[0]>$row[1]</option>";}
mysql_close;?>
</select></td></tr><?} while ($row1=mysql_fetch_assoc($sql1));}}?></td>
?>