You can click here to see the checkbox output.
My problem is, I want to create a checkbox. But, when I add the for loop statement, the amount of the checkbox is the same as amount of "no" in each cell. (you can click the "You can click here to see the checkbox output." link above to see. For example, if "no" is 5, the checkbox will appeared in 5 times. I want the checkbox is appeared 1 only in each table cell but the same amount with "no". I hope you understand what I mean. I know the problem is the for loop statement but, I don't know how to fix them. Please help me.
$result=mysql_query("SELECT * FROM peralatansukan");
$count=mysql_num_rows($result);
echo "<table width='50%' border='1'>";
echo"<tr>";
echo"<td align='center'><b>No.</b></td>";
echo"<td align='center'><b>Peralatan Sukan</b></td>";
echo"<td align='center'><b>Kuantiti</b></td>";
echo"<td align='center'><b>Pinjam</b></td>";
echo"</tr>";
if($count==0)
{echo "no record found";
}
else {
while($row=mysql_fetch_array($result))
{
echo "<tr>";
echo "<td align='center'>".$row["no"]."</td>";//no
echo "<td align='center'>".$row["peralatansukan"]."
</td>";//peralatansukan
//kuantiti
echo "<td align='center'>";
echo "<select name=quantity value=''>";
for($x = 1; $x<=$row['kuantiti']; $x++){
echo "<option value=$x>$x</option>";
}
echo "</select></td>";
//pinjam
echo "<td align='center'>";
for($y = 1; $y<=$row['no']; $y++){
echo "<input type='checkbox' value='ya'>";
}
echo "</td>";
echo "</tr>";
}
}
echo "</table>";
?>
Aucun commentaire:
Enregistrer un commentaire