Couple of Gotchas when doing this.
[$i] = had to be used as an array so I could loop through the records.
[] = doing that alone did nothing for my code and might not work for your's either.
i++ = then it's able to seperate the arrrays and line them up with the proper records and of course count as many as I need, I think.
Another pretty big piece was that hidden inputs were needed for the 2 checkboxes so that the field will remain a "N" if nothing is checked. Wow, that was a pain as well.
<?
////////////////////////////////
///This page is triggered by QueryTotals3.php
//////////////////////////////
////////////////////////////////
//// Change N to Y when the have Paid
//////////////////////////////////
?>
<?
//////Grab the data as normal,
?>
<?
$db_name2 = "stuff";
$table_name2 = "table";
$connection2 = @mysql_connect("$host", "$username") or die ("Could not connect2.");
$db2 = @mysql_select_db($db_name2, $connection2) or die ("no db connection2");
$sql2 = "select jurisdiction, totaltofund, funded, moneypaid, postdate, autokey from
$table_name2 where postdate = $processdate";
$result2 = mysql_query($sql2,$connection2) or die ("posxxxxTop2");
$count2 = mysql_num_rows($result2);
?>
<?
$color1 = "white";
$color2 = "D3D3D3";
$row_count1 = 0;
?>
<form name=stuff5 method=post action=markaspaid.php>
<table width = 50% border=1 cellspacing=1>
<tr>
<th><font size=-1>ID</font></th>
<th><font size=-1>Jur</font></th>
<th><font size=-1>Postdate</font></th>
<th><font size=-1>Total<br>Reported</font></th>
<th><font size=-1>Total<br>To Fund</font></th>
<th><font size=-1>Account<br>Funded</font></th>
<th><font size=-1>Payment<br>Made</font></th>
<th><font size=-1>Funded?</font></th>
<th><font size=-1>Paid?</font></th>
</tr>
<?
while ($row2 = mysql_fetch_array($result2)) {
$autokey2 = $row2['autokey'];
$jurisdiction2 = $row2['jurisdiction'];
$totaltofund2 = $row2['totaltofund'];
$postdate2 = $row2['postdate'];
$funded2 = $row2['funded'];
$moneypaid2 = $row2['moneypaid'];
?>
<? echo "
<tr>$autokey2</td>
<td >$base_jurisdiction2</td>
<td>$postdate2</td>
<td>$totaltofund2</td>
<td>$totaltofund3</td>
<td>$funded2</td>
<td>$moneypaid2</td>
<input type=hidden name=fundbox3[$i] value=N></input>
<td><input type=checkbox name=fundbox3[$i] value=Y></td></input>
<input type=hidden name=paidbox3[$i] value=N></input>
<td><input type=checkbox name=paidbox3[$i] value=Y></td></input>
</tr>
<input type=hidden name=autokey3[$i] value=$autokey2></input>
<input type=hidden name=jurisdiction3[$i] value=$base_jurisdiction2></input>
";
$i++;
$row_count1++;
}
?>
<?
echo "<tr>";
echo "<td></td><td></td><td></td><td></td><td></td><td></td><td></td>";
echo "<td align=right ><input type=submit value=Funded name=Funded></td><br>";
echo "<td align=right><input type=submit value=MarkPaid name=MarkPaid></td><br>";
echo "</tr>";
echo "</form>";
echo "</table>";
?>
</table>
<html>
<body>
<title>Summary Totals</title>
<BODY BGCOLOR="#FFFFFF">
</body>
</html>
The processing page
Gotchas:
I could not update the field in the Record unless I specified what was in the Record to begin with. I don't know if this is just my bad programming or a limitation.
Thus trying to update the field by merely calling out the AutoID number was not good enough. It also had to know if the 'Moneypaid' field contains a 'N' as well.
Not sure why it has to know what's in the field though? Pain in the ass for sure.
I was also having issues with UPDATING 2 fields at once, or just one of 2 fields or even both.
The original form has 2 Checkboxes. I simply made to Submit buttons. Messy, but it works.
<?////////////////////////////////
//// Change N to Y when they have Paid
//////////////////////////////////
?>
<?php
if ($MarkPaid == "MarkPaid")
include "connect.php";
$fieldlength = 5;
for ($i=0; $i <= $fieldlength; $i++)
{
echo
$sql = "UPDATE fundsnettingtotal set moneypaid = '$paidbox3[$i]'
where jurisdiction = '$jurisdiction3[$i]' and moneypaid = 'N'
";
$result = mysql_query($sql, $db);
}
mysql_free_result($result);
mysql_close($db);
//header("Location: fullnettotals5.php?processdate=$postdate");
//exit;
?>
<?php
if ($Funded == "Funded")
include "connect.php";
$fieldlength = 5;
for ($i=0; $i <= $fieldlength; $i++)
{
echo
$sql = "UPDATE fundsnettingtotal set funded = '$fundbox3[$i]'
where base_jurisdiction = '$base_jurisdiction3[$i]' and funded = 'N'
";
$result = mysql_query($sql, $db);
}
mysql_free_result($result);
mysql_close($db);
//header("Location: fullnettotals5.php?processdate=$postdate");
//exit;
?>