Originally posted by sfullman
Since you're looking for a status of "NO" I won't go into how things should include "checked" in the tag.
I got the previous one working but now I now need to do exactly what you said above for another script that i'm writing. since im on a deadline i havent changed all the echo's but i'll bear in mind for the future what you said earlier
Anyway, here are the scripts:
viewRespondList.php
<?php
include("dbconnect.php");
$results = mysql_query("SELECT * FROM Contact,Enquiry WHERE (Enquiry.live = 'yes') AND (Contact.contactID = Enquiry.contactID)") or die(mysql_error());
echo "<form method=\"POST\" action=\"updateRespondList.php\">";
echo "<table border= \"1\">\n";
echo "<tr>\n";
echo "<td>Contact ID</td>\n";
echo "<td>Name</td>\n";
echo "<td>Surname</td>\n";
echo "<td>DoB</td>\n";
echo "<td>Address</td>\n";
echo "<td>Tel No.</td>\n";
echo "<td>Email</td>\n";
echo "<td>Live Enquiry:Yes/No?</td>\n";
echo "</tr>\n";
while ($row = mysql_fetch_array($results)){
echo "<tr>\n";
echo "<td>";
echo $row["contactID"];
echo "</td>\n";
echo "<td>";
echo $row["firstname"];
echo "</td>\n";
echo "<td>";
echo $row["surname"];
echo "</td>\n";
echo "<td>";
echo $row["DoB"];
echo "</td>\n";
echo "<td>";
echo $row["address"];
echo "</td>\n";
echo "<td>";
echo $row["telNumber"];
echo "</td>\n";
echo "<td>";
echo $row["email"];
echo "</td>\n";
echo "<td>";
//$enquiries[$row["enquiryID"]];
?>
<input type="checkbox" name= liveEnquiry[<?php echo $row["enquiryID"];?>] value="TRUE" checked>
<?php echo "</td>\n";
}
echo "</table>\n";
echo "<br>\n";
echo "<input type=\"submit\" value=\"Submit\" name=\"submit\">\n";
echo "</form>";
mysql_free_result($results);
?>
updateRespondList.php
<?php
include("dbconnect.php");
$_POST['submit']=$Submit;
if($submit == "Submit"){
if(is_array($liveEnquiry)){
foreach($liveEnquiry as $n=>$v){
if($n == FALSE){
$staffID = $_SESSION['staffID'];
$history = "INSERT INTO History (Details,timeStamp,applicationID,staffID,enquiryID,contactID) VALUES ('enquiryResponse',NOW( ),NULL,'$staffID','$n','$n')";
$update="UPDATE EnquirySET live = 'no' WHERE enquiryID = '$n'";
mysql_query($update) or die(mysql_error());
mysql_query($history) or die(mysql_error());
}
}
}
include("viewRespondList.php");
}
?>
Thanks for all your help 🙂