Reputation: 39
I need to fix this code I dont understand what is wrong with the checkbox.
if ($result->num_rows > 0) { // this is the if statement
echo "<table border='1'><tr>
<th>ID</th>
<th>Usernames</th>
<th>Password</tr>"; //table headings
// output data of each row
while($row = $result->fetch_assoc()) {
echo "<tr>
<td>".$row["ID"]."</td>
<td>".$row["Username"]."</td>
<td>".$row<input type='checkbox'/>."</td> //this part needs to be fixed
</tr>"; // the problem is in this table
}
echo "</table>";// the code runs using a database and all information on the sql is correct
} else {
echo "0 results";
}
Upvotes: 1
Views: 480
Reputation: 41810
Not sure exactly what you're going for, but something like this should work for that line.
<td><input type='checkbox' name='something' value='".$row['ID']."' /></td>
In your original code, the HTML for the checkbox was not part of the string, but instead looked like it was trying to be part of the $row
variable, which was a syntax error.
Upvotes: 1