I am working on a web page in PHP and MySql. I've been using
Dreamweaver MX 2004. The web page lists a user's properties using the
"repeat region" behavior. Beside every property, there is a checkbox
with the value of the user's property (name of the checkbox is
"propertyname". I need the user to be able to check multiple
properties, and with the update button, have a column in the database
updated with the current time. Right now, only one property's
"dateforformatcounter" is updated, regardless of how many checkboxes
are checked.
Here is the code:
<?php require_once('Connections/connectdb.php'); ?>
<?php
// Load the tNG classes
require_once('includes/tng/tNG.inc.php');
function GetSQLValueString($theValue, $theType, $theDefinedValue = "",
$theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
$updateSQL = sprintf("UPDATE owner_prop SET dateformatforcounter=%s
WHERE Propertyname=%s",
GetSQLValueString($_POST['update'], "text"),
GetSQLValueString($_POST['propertyname'], "text"));
mysql_select_db($database_connectdb, $connectdb);
$Result1 = mysql_query($updateSQL, $connectdb) or die(mysql_error());
}
$colname_Recordset1 = "-1";
if (isset($_COOKIE['UserName'])) {
$colname_Recordset1 = (get_magic_quotes_gpc()) ?
$_COOKIE['UserName'] : addslashes($_COOKIE['UserName']);
}
mysql_select_db($database_connectdb, $connectdb);
$query_Recordset1 = sprintf("SELECT * FROM owner_prop WHERE owner =
'%s' ORDER BY dateformatforcounter DESC", $colname_Recordset1);
$Recordset1 = mysql_query($query_Recordset1, $connectdb) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr;
for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++)
x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++)
x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array;
for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc)
x.oSrc=x.src; x.src=a[i+2];}
}
function checkAll(field)
{
for (i = 0; i < field.length; i++)
field[i].checked = true ;
}
//-->
</script>
<link href="/para1.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
a:link {
color: #FFFFFF;
}
.Pararegspace {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
line-height: 14px;
font-weight: bold;
}
-->
<style type="text/css">
<!--
form {
margin: 0;
padding: 0;
}
.style15 {font-size: small}
-->
</style>
</head>
<body bgcolor="#CCCCCC" vlink="#000000" alink="#000000"
onLoad="MM_preloadImages('/Images/Headings/on/MAIL_ON.gif','/Images/Headings/on/ADD%20NEW%20PROPERTY_ON.gif','/Images/Headings/on/DELETE%20PROPERTY_ON.gif','/Images/Headings/on/CHANGE%20PASSWORD_ON.gif','/Images/Headings/on/SIGN-OUT_ON.gif','/Images/Headings/on/MODIFY%20ACCOUNT%20INFO_ON.gif','/Images/Headings/on/CLAIMREWARD_ON.gif','/Images/Headings/on/CONTACTUS_ON.gif')">
<table width="725" border="0" align="center" cellpadding="0"
cellspacing="0"><form action="<?php echo $editFormAction; ?>"
name="form1" method="POST">
<tr>
<td colspan="10"><div align="center"><img
src="/Images/consoleowners65trimmed.gif" width="267"
height="62"></div></td>
</tr>
<tr>
<td colspan="10"><img src="/Images/spacer1x6.gif" width="1" height="6"></td>
</tr>
<tr>
<td colspan="10" bgcolor="#14336A"><img
src="/Images/spacer1x6.gif" width="1" height="6"></td>
</tr>
<tr>
<td width="6" bgcolor="#14336A"> </td>
<td width="62" bgcolor="#BBCAE5"><div align="center"><a href="#"
onMouseOut="MM_swapImgRestore()"
onMouseOver="MM_swapImage('Image5','','/Images/Headings/on/MAIL_ON.gif',1)"><img
src="/Images/Headings/MAIL.gif" name="Image5" width="31" height="12"
border="0"></a></div></td>
<td width="94" height="35" bgcolor="#BBCAE5"><div
align="center"><a href="owners_newprop.php"
onMouseOut="MM_swapImgRestore()"
onMouseOver="MM_swapImage('Image6','','/Images/Headings/on/ADD%20NEW%20PROPERTY_ON.gif',1)"><img
src="/Images/Headings/ADD%20NEW%20PROPERTY.gif" name="Image6"
width="64" height="28" border="0"></a></div></td>
<td width="94" bgcolor="#BBCAE5"><div align="center"><a href="#"
onMouseOut="MM_swapImgRestore()"
onMouseOver="MM_swapImage('Image7','','/Images/Headings/on/DELETE%20PROPERTY_ON.gif',1)"><img
src="/Images/Headings/DELETE%20PROPERTY.gif" name="Image7" width="63"
height="28" border="0"></a></div></td>
<td width="121" bgcolor="#BBCAE5"><div align="center"><a
href="owner_modify_account_info.php" onMouseOut="MM_swapImgRestore()"
onMouseOver="MM_swapImage('Image12','','/Images/Headings/on/MODIFY%20ACCOUNT%20INFO_ON.gif',1)"><img
src="/Images/Headings/MODIFY%20ACCOUNT%20INFO.gif" name="Image12"
width="91" height="28" border="0"></a></div></td>
<td width="100" bgcolor="#BBCAE5"><div align="center"><a
href="owner_modify_account_pw.php" onMouseOut="MM_swapImgRestore()"
onMouseOver="MM_swapImage('Image9','','/Images/Headings/on/CHANGE%20PASSWORD_ON.gif',1)"><img
src="/Images/Headings/CHANGE%20PASSWORD.gif" name="Image9" width="70"
height="28" border="0"></a></div></td>
<td width="86" bgcolor="#BBCAE5"><div align="center"><a href="#"
onMouseOut="MM_swapImgRestore()"
onMouseOver="MM_swapImage('Image16','','/Images/Headings/on/CLAIMREWARD_ON.gif',1)"><img
src="/Images/Headings/CLAIM%20REWARD.gif" name="Image16" width="55"
height="28" border="0"></a></div></td>
<td width="88" bgcolor="#BBCAE5"><div align="center"><a href="#"
onMouseOut="MM_swapImgRestore()"
onMouseOver="MM_swapImage('Image17','','/Images/Headings/on/CONTACTUS_ON.gif',1)"><img
src="/Images/Headings/CONTACT%20US.gif" name="Image17" width="58"
height="28" border="0"></a></div></td>
<td width="92" bgcolor="#BBCAE5"><div align="center"><a href="#"
onMouseOut="MM_swapImgRestore()"
onMouseOver="MM_swapImage('Image11','','/Images/Headings/on/SIGN-OUT_ON.gif',1)"><img
src="/Images/Headings/SIGN_OUT.gif" name="Image11" width="60"
height="13" border="0"></a></div></td>
<td width="6" bgcolor="#14336A"> </td>
</tr>
<tr>
<td colspan="10" bgcolor="#14336A"><img
src="/Images/spacer1x6.gif" width="1" height="6"></td>
</tr>
<tr bgcolor="#CCCCCC">
<td colspan="10"><div align="center" class="para1"></div></td>
</tr>
<tr bgcolor="#CCCCCC">
<td colspan="10">
<table width="750" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="25"> </td>
<td width="107"><input type="submit" name="Submit"
value="Renew Checked"></td>
<td width="10"> </td>
<td width="68"><span class="para1">
<input name="Checkall" type="button" id="Checkall"
onClick='checkAll(this.form,list)' value='Check all'/>
</span></td>
<td width="19"> </td>
<td width="282"><div align="center"><span
class="para1"><font color="#000000"><?php echo $_COOKIE['UserName'];
?>,
you have <?php echo $totalRows_Recordset1 ?>
properties</font></span></div></td>
<td width="42"> </td>
<td width="195"><span class="para1"><strong class="Pararegspace">
<input name="update" type="hidden" id="update"
value="<?php echo date('F jS, Y G:i:sT'); ?>">
</strong></span></td>
</tr>
</table>
<tr bgcolor="#BBCAE5">
<td height="108" colspan="10">
<?php do { ?>
<table width="750" border="4" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="20" rowspan="2" bordercolor="#BBCAE5"><div align="center">
<input type="checkbox" name="propertyname"
id="propertyname" value="<?php echo $row_Recordset1['Propertyname'];
?>">
</div></td>
<td width="46" rowspan="2" align="center" valign="middle"
bgcolor="#000000"><div align="center"><a
href="/owners_newprop_previewit3.php?Uprop=<?php echo
$row_Recordset1['Propertyname']; ?>"><img src="<?php echo
tNG_showDynamicThumbnail("", "upload/{Recordset1.Propertyname}/",
"{Recordset1.photo1}", 140, 100, true); ?>" border="5"
align="absmiddle" /></a></div></td>
<td width="0" height="65" align="left" valign="top"
bordercolor="#BBCAE5" bgcolor="#BBCAE5"
class="para1"><strong></strong><a
href="/owners_property_details.php?Uprop=<?php echo
$row_Recordset1['Propertyname']; ?>"><font
size="2"><strong></strong></font></a></td>
<td width="315" align="left" valign="top"
bordercolor="#BBCAE5" bgcolor="#BBCAE5" class="para1"><a
href="/owners_property_details.php?Uprop=<?php echo
$row_Recordset1['Propertyname']; ?>" class="Biggerpara"></a><a
href="/owners_newprop_previewit3.php?Uprop=<?php echo
$row_Recordset1['Propertyname']; ?>" class="Biggerpara"><font
color="#14336A" face="Arial, Helvetica, sans-serif"><?php echo
$row_Recordset1['Propertyname']; ?></font></a><br>
Renew within: <a name="yoyo" class="Countdown">
<?php
$startDate = $row_Recordset1['dateformatforcounter'];
$thirtyDays = date("F jS, Y G:i:sT", strtotime($startDate) + 60*60*24);
$threesixtyHours = date("F jS, Y G:i:sT", strtotime($startDate) + 60*60*360);
// enter start date below like this: "January 2, 2001"
$end = $threesixtyHours;
// enter string of what this start date is.
$text = "";
$textOnTheDay = "";
$textAfterwards = "This property has expired!";
//-
$now = strtotime ("now");
$then = $then = strtotime ("$end");
$difference = $then - $now;
$num = $difference/86400;
$days = intval($num);
$num2 = ($num - $days)*24;
$hours = intval($num2);
$num3 = ($num2 - $hours)*60;
$mins = intval($num3);
$num4 = ($num3 - $mins)*60;
$secs = intval($num4);
if ($days>0 || $hours>0 || $minutes>0 || $seconds>0) {
echo "$days days, ";
echo "$hours hours, ";
echo "$mins minutes";
echo $text;
} else if ($days<=5){ ?>
</a><a name="yoyo" class="Countdown"><a class="Countdownred"> <?
echo "$days days, ";
echo "$hours hours, ";
echo "$mins minutes";
echo $text;
} else if (($days==0) && ($hours<=0 || $minutes<=0 || $seconds<=0)) {
echo $textOnTheDay;
} else {
echo $textAfterwards;
} ?></a></a> <br>
Created: <?php echo $row_Recordset1['datecreated']; ?><br>
Last Modified: <strong class="para1"><?php echo
$row_Recordset1['timestamp']; ?></strong></td>
<td width="24" rowspan="2" align="left" valign="middle"
bordercolor="#BBCAE5" class="para1"> </td>
<td width="323" rowspan="2" align="left" valign="middle"
bordercolor="#BBCAE5" class="para1"><strong class="Pararegspace">Type:
<?php echo $row_Recordset1['propertytype']; ?><br>
Rent: $<?php echo $row_Recordset1['monthlyrent']; ?>.00<br>
Security Deposit: $<?php echo $row_Recordset1['securitydeposit']; ?>.00<br>
Lease: <?php echo $row_Recordset1['leaseduration']; ?><br>
Square Feet: <?php echo $row_Recordset1['sqft']; ?> sq ft. <br>
Bedrooms: <?php echo $row_Recordset1['bedrooms']; ?><br>
Bathrooms: <?php echo $row_Recordset1['bathrooms']; ?>
</strong></td>
</tr>
<tr>
<td height="36" colspan="2" align="left" valign="bottom"
bordercolor="#BBCAE5"><div align="left"><a
href="/owners_newprop_previewit3.php?Uprop=<?php echo
$row_Recordset1['Propertyname']; ?>"><img src="<?php echo
tNG_showDynamicThumbnail("", "upload/{Recordset1.Propertyname}/",
"{Recordset1.photo2}", 70, 50, true); ?>" width="80" height="50"
border="1" align="bottom" /></a><a
href="/owners_newprop_previewit3.php?Uprop=<?php echo
$row_Recordset1['Propertyname']; ?>"><img src="<?php echo
tNG_showDynamicThumbnail("", "upload/{Recordset1.Propertyname}/",
"{Recordset1.photo3}", 70, 50, true); ?>" width="80" height="50"
border="1" align="bottom" /></a><a
href="/owners_newprop_previewit3.php?Uprop=<?php echo
$row_Recordset1['Propertyname']; ?>"><img src="<?php echo
tNG_showDynamicThumbnail("", "upload/{Recordset1.Propertyname}/",
"{Recordset1.photo4}", 70, 50, true); ?>" width="80" height="50"
border="1" align="bottom" /></a><a
href="/owners_newprop_previewit3.php?Uprop=<?php echo
$row_Recordset1['Propertyname']; ?>"><img src="<?php echo
tNG_showDynamicThumbnail("", "upload/{Recordset1.Propertyname}/",
"{Recordset1.photo5}", 70, 50, false); ?>" width="80" height="50"
border="1" align="bottom" /></a></div></td>
</tr>
</table>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
<input type="hidden" name="MM_update" value="form1"
action="<?php echo $editFormAction; ?>">
<input type="hidden" name="MM_update" value="form1">
</form></td>
</tr>
</table>
<table width="750" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td> </td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td> </td>
</tr>
</table>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>
Thanks. |