I can't figure out why I cannot update multiple records at the same time. Here is my code
and then
But that only updates the last record.
Any hints on how to change all records at the same time?
Thanks in advance
Code:
while( @emps = $sth->fetchrow) {
$MLSNumber = $emps[0];
$SatHourFrom = $emps[1];
$SatMinutesFrom = $emps[2];
$SatHourTo = $emps[3];
$SatMinutesTo = $emps[4];
$SunHourFrom = $emps[5];
$SunMinutesFrom = $emps[6];
$SunHourTo = $emps[7];
$SunMinutesTo = $emps[8];
$Headline1 = $emps[9];
$Headline2 = $emps[10];
$ListingPriceFrom = $emps[11];
$IncludePlusSign = $emps[12];
$ListingPriceTo = $emps[13];
$Description1 = $emps[14];
$Description2 = $emps[15];
$StreetAddress = $emps[16];
$CityName = $emps[17];
$CityNameOther = $emps[18];
$AgentName1 = $emps[19];
$AgentName1Phone1 = $emps[20];
$AgentName1Phone2 = $emps[21];
$Agent1Days = $emps[22];
$AgentName2 = $emps[23];
$AgentName2Phone1 = $emps[24];
$AgentName2Phone2 = $emps[25];
$Agent2Days = $emps[26];
$MarketedBy = $emps[27];
$MarketedByDays = $emps[28];
$bFeatureHome = $emps[29];
$yahoo = $emps[30];
$Active = $emps[31];
print <<OH;
<form Action="openhouseAdmin.cgi" Method="post" name="frm1" id ="frm1">
<input type='hidden' name="action" value="activeconfirm2">
<input type='hidden' name="city" value="$input{'city'}">
<input type='hidden' name="MLSNumber" value="$input{'MLSNumber'}">
<tr>
<td><FONT CLASS="BodyBold"> $CityName</FONT></td>
<td><FONT CLASS="BodyBold">$StreetAddress</FONT></td>
OH
if ($Active eq "yes") {
$checkedyes = "checked";
$checkedno = "";
} else {
$checkedno = "checked";
$checkedyes = "";
}
print <<OH;
<td align ="Center"><input type="checkbox" name="Active" value="yes" $checkedyes><input name="MLSNumber" type="Hidden" value="$MLSNumber"></td>
</tr>
OH
}
print <<OH;
</table> <br /><br />
<input type='checkbox' name='checkall' onclick='checkedAll(frm1);'> Check to make all Active, Uncheck to make all Non-Active<br />
<input type="Submit" Name="Submit" Value="Change"></form>
OH
$sth->finish ();
$dbh->disconnect();
and then
Code:
if ($input{'action'} eq 'activeconfirm2'){
if ($input{Active} eq "") {
$input{Active} = "No";
}
$sth = $dbh->prepare ("SELECT * FROM events where MLSNumber = '$input{MLSNumber}'");
$sth->execute ();
$sth = "UPDATE events SET Active = '$input{Active}' WHERE MLSNumber = '$input{MLSNumber}'";
$dbh->do( $sth ) or die( $dbh->errstr );
&header;
print <<OH;
print "
<script language=\"JavaScript\">
<!-- Begin
var name = navigator.appName;
if (name == \"Microsoft Internet Explorer\")
url=(\"openhouseAdmin.cgi?action=active2&city=$input{'city'}\");
else
url=(\"openhouseAdmin.cgi?action=active2&city=$input{'city'}\");
window.location=url;
// End -->
</script>
";
OH
But that only updates the last record.
Any hints on how to change all records at the same time?
Thanks in advance