My project works completely fine not until I inserted the image tag, that's where looping and the position of the checkbox, label and image gone wrong.
See this image below:
This is what happened when I tried to insert the img tag together with the checkbox and label
this is the whole code that I created.
HTML, PHP
<!DOCTYPE html>
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="structure.css">
</head>
<body>
<form action="another_sample.php" method="POST">
<?php
include "connection.php";
$sql = "SELECT m.type, m.name, m.price, m.image, mt.name as 'type' FROM table_menu m LEFT JOIN table_menu_type mt ON m.type = mt.id WHERE m.type LIKE '%1%' ";
$result = $con->query($sql);
if ($result->num_rows > 0) {
// output data of each row
$x = 1;
while($row = $result->fetch_assoc()) {
echo "<label><input type='checkbox' name='food[]' value ='". $row['price']."'>";
echo $row['name']."</label> <br>";
echo "<img class='img-foods' src='food_menu/". $row['image'] ."'>";
$x++;
if($x > 3){
echo "<br>";
$x=1;
}
}
}
else {
echo "0 results";
}
$con->close();
?>
</form>
</body>
</html>
Aucun commentaire:
Enregistrer un commentaire