I have an "order_details" table with columns "OrderID", "ProductID", "UnitPrice", and "Quantity". Using the rows of these columns, I use the following code to generate checkboxes. I would like to add a "SelectAll" checkbox beside each row of checkboxes. How can I do that please? thanks.
My checkbox form now looks like this:
Here is the code: checkbox.php
<!doctype html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<?php
include 'dbconfig.php';
$subjectName = "SELECT * FROM order_details";
$subject = mysql_query( $subjectName, $conn );
?>
<h2> Select Order</h2>
<form method="post" action=" ">
<?php
while($data = mysql_fetch_array($subject)) {
echo "<input type='checkbox' value='{$data['OrderID']}'>" . $data['OrderID'] ;
echo "<input type='checkbox' value='{$data['ProductID']}'>" . $data['ProductID'] ;
echo "<input type='checkbox' value='{$data['UnitPrice']}'>" . $data['UnitPrice'] ;
echo "<input type='checkbox' value='{$data['Quantity']}'>" . $data['Quantity'] . '</br>';
}
?>
</form>
</body>
</html>
dbconfig.php
<?php
$hostname = "localhost";
$username = "root";
$password = "";
$dbname = "Orders";
$conn = mysql_connect($hostname, $username, $password);
if (!$conn)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db($dbname, $conn);
?>
Aucun commentaire:
Enregistrer un commentaire