I actually have a very limited knowledge of php and had dreamweaver write most of the code for me. I then tried to add the 'for' loop afterwards. Perhaps it will make sense if I show you the entire document:
<?php require_once('../Connections/victoria.php'); ?>
<?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")) {
for ($i = 0; $i < count($POST['dayID']); $i++);
$updateSQL = sprintf("UPDATE tbl_day SET dayInput='".$POST['dayInput'][$i]."' WHERE dayID='".$_POST['dayID']
[$i]."'",
GetSQLValueString($POST['dayInput'], "text"),
GetSQLValueString($POST['dayID'], "int"));
}
mysql_select_db($database_victoria, $victoria);
$Result1 = mysql_query($updateSQL, $victoria) or die(mysql_error());
$updateGoTo = "editCalendar10.php";
if (isset($SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $SERVER['QUERY_STRING'];
header(sprintf("Location: %s", $updateGoTo));
}
$colname_dayRS = "-1";
if (isset($GET['monthID'])) {
$colname_dayRS = (get_magic_quotes_gpc()) ? $GET['monthID'] : addslashes($_GET['monthID']);
}
mysql_select_db($database_victoria, $victoria);
$query_dayRS = sprintf("SELECT * FROM tbl_day WHERE monthID = %s ORDER BY dayID ASC", $colname_dayRS);
$dayRS = mysql_query($query_dayRS, $victoria) or die(mysql_error());
$row_dayRS = mysql_fetch_assoc($dayRS);
$totalRows_dayRS = mysql_num_rows($dayRS);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<form method="post" name="form1" action="<?php echo $editFormAction; ?>">
<table align="center">
<?php do { ?>
<tr valign="baseline">
<td nowrap align="right">DayNumber:</td>
<td><?php echo $row_dayRS['dayNumber']; ?></td>
<td align="right" nowrap="nowrap">DayInput:</td>
<td><input name="dayInput[]" type="text" id="dayInput[]" value="<?php echo $row_dayRS['dayInput']; ?>" size="32" /></td>
</tr>
<?php } while ($row_dayRS = mysql_fetch_assoc($dayRS)); ?>
<tr valign="baseline">
<td nowrap align="right"> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr valign="baseline">
<td nowrap align="right"> </td>
<td><input type="submit" value="Update record"></td>
<td> </td>
<td> </td>
</tr>
</table>
<input type="hidden" name="MM_update" value="form1">
<input name="dayID[]" type="hidden" id="dayID[]" value="<?php echo $row_dayRS['dayID']; ?>">
</form>
<p> </p>
</body>
</html>
<?php
mysql_free_result($dayRS);
?>
This now gives me 'query was empty'. Any ideas?