Forum Moderators: coopster
Here is a part of php code
<?
while ($row = mysql_fetch_assoc($result)){
foreach ($row as $col=>$val){
print " $val " ;
$j=0;
for ($i=0; $i<=5; $i++){
$j=$j+1;
echo ' <input id="<?php echo $j; ?>" name="1" type="checkbox" value="" />
';
}
// $content .= "<div align=\"center\">"; <input id='$j'; name="1" type="checkbox" value="" />';
print "<br /> <br />";
}}
?>
<?
$j=0;
for ($i=0; $i<=5; $i++){
$j++;
echo '<input id="'.$j.'" name="1" type="checkbox" value="" />';
}
?>
Variables inside single quotes will not be evaluated, which is why you need to concatinate. Alternatively, you can also use echo "<input id=\"$j\" name=\"1\" type=\"checkbox\" value=\"\" />";
echo ' <input id="<?php echo $j; ?>" name="1" type="checkbox" value="" />
You are already in a PHP code block, so you shouldn't be trying to open another code block within it...
echo ' <input id="chk'.$j.'" name="chk1" type="checkbox" value="" />
Also, I've added a prefix of 'chk' to your ID and NAME attributes since these must start with a letter (Use any letter - HTML standard).
...if id not start with a letter where is the problem? just for html standard?
ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").
Source: http://www.w3.org/TR/html4/types.html#type-name
Yes, HTML standard. But if you don't follow the standards then it might not work in all/future browsers. There is usually a reason for the standards, they are not intended to make things harder. It could also be a problem with PHP. If
register_globalsis set then PHP will create a variable that matches your NAME attribute. PHP cannot have variables that start with a number either.