Forum Moderators: coopster
<?php
// Get results from table
$result = mysql_query("SELECT * FROM $tbl_name WHERE sent=0")
or die(mysql_error());
echo "<table border='1'>";
echo "<tr> <th>ID</th> <th>First Name</th> <th>Surname</th> <th>Address1</th> <th>Address2</th> <th>Town/City</th> <th>County</th> <th>Post Code</th> <th>Request Date</th> <th>Sent</th> <th>-------</th> </tr>";
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )){
// Print out the contents of each row into a table
echo "<tr><td>";
echo $row['request'];
echo "</td><td>";
echo $row['firstname'];
echo "</td><td>";
echo $row['surname'];
echo "</td><td>";
echo $row['address1'];
echo "</td><td>";
echo $row['address2'];
echo "</td><td>";
echo $row['town'];
echo "</td><td>";
echo $row['county'];
echo "</td><td>";
echo $row['postcode'];
echo "</td><td>";
echo $row['date'];
echo "</td><td>";
echo "<input type='checkbox' name='shipped[]' value='1'>";
echo "</td><td>";
echo '<input type="button" name="print" value="Print" onclick="document.location.href=\'create_pdf_shipping_label.php\'">';
echo "</td></tr>";
}
echo "<tr>";
echo "<th></th>";
echo "<th></th>";
echo "<th></th>";
echo "<th></th>";
echo "<th></th>";
echo "<th></th>";
echo "<th></th>";
echo "<th></th>";
echo "<th></th>";
echo "<th>
<form action='update.php' method='POST'>
<input name='sent' value='shipped[]' type='hidden'>
<input type='submit' name='Submit' value='Submit'>
</th>";
echo "<th></th>";
echo "</tr>";
echo "</table>";
echo "<br>";
$num_rows = mysql_num_rows($result);
echo "$num_rows samples are awaiting shipment.<br>";
echo "Updated on: ".date("l, F d, T h:i" ,time());
echo "<br>";
?> <?php
error_reporting(E_ALL|E_STRICT);
require_once("connections/connection.php"); // Connection to the server
$tbl_name="sample_requests"; // Table name
if (isset($_POST['Submit']) && $_POST['Submit'] == 'Submit')
{
$requestid = ($_POST['sent']);
$sql = mysql_query("UPDATE $tbl_name SET sent = 1 WHERE request = '$requestid' ");
$result = mysql_query($sql);
}
header("location:view_sample_requests.php");
exit;
?> $requestid = ($_POST['sent']);
echo "<input type='checkbox' name='shipped[]' value='1'>";
...
<input name='sent' value='shipped[]' type='hidden'>
foreach ($_POST['shipped'] as $k=>$v)
{
if (intval($v)) ...update request $v...
}
echo "<input type='checkbox' name='shipped[$request]' value='1'>";
... and then ...
foreach ($_POST['shipped'] as $k=>$v)
{
if (intval($k)&&$v==1) ...update request $k...
}