for readability, my comments are prefaced with '####'
$sql = "select * from users where authorised=0";
$result = mysql_query($sql);
$numrows = mysql_num_rows($result);
what's this line for? why not $auths = mysql_num_rows($result); ?
$auths = $numrows;
if ($numrows > 0) {
echo "<h3>Authorisation List</H3><P>\n";
echo " There are currently $auths new accounts needing authorising";
echo "<FORM method=\"post\" action=\"$PHP_SELF?command=runauth\"> ";
echo "<TABLE width=\"100%\" border=\"0\">";
echo "<TR>\n";
echo "<TH width=10>Authorise</TH>\n";
echo "<TH>Company Name</TH>\n";
echo "<TH>Contact Name</TH>\n";
echo "<TH>Telephone</TH>\n";
echo "<TH>City</TH>\n";
echo "<TH>Options</TH>\n";
echo "</TR>\n";
while ($auth =mysql_fetch_array($result)) {
$clientsql = "select * from landlords where ID='" . $auth["ID"] . "'";
$cresult = mysql_query($clientsql);
for ($i=0;$i<count($auths);$i++) {
ah-ha! count() is used for the elements of an array.
you just need $i<$auths
while ($client = mysql_fetch_array($cresult)) {
ECHO "<input type=\"hidden\" name=\"ID".$i."\" value=\"" . $auth["ID"]
. "\">\n";
echo "<TR>";
echo "<TD><input type=\"checkbox\" name=\"authorised".$i."\"
value=\"1\" class=\"dsinput\"></TD>\n";
echo "<TD>\n";
echo "" . $client["company_name"] . "</TD>\n";
echo "<TD>" . $client["contact_name"] . "</TD>\n";
echo "<TD>" . $client["contact_tel"] . "</TD>\n";
echo "<TD>" . $client["city"] . "</TD>\n";
echo "<TD align=middle><a href=\"$PHP_SELF?command=modifyclient&ID="
.$auth["ID"] . "\">MODIFY</a>\n | <a OnClick=\"if (confirm('Are you
sure you wish to delete this record?') != true) return false;\"
href=\"$PHP_SELF?command=removeclient&ID=" .$auth["ID"] .
"\">REMOVE</A></TD>\n";
}
}
}
echo "<TR><TD colspan=6>\n<INPUT type=\"submit\" value=\"Authorise\"
class=\"button\" style=\"background: #003399; width: 100;\"
onMouseOver=\"this.style.background='#FF9900'\"
onMouseOut=\"this.style.background='#003399'\"></TD>\n";
echo "<TABLE>\n";
}else{
echo "nothing to authorise";
}
break;
case "runauth":
$sql = "update users set authorised='" . $authorised[$x] . "' ,
assuming this $authorised[$x] is the result of the form above, won't you
instead be getting $authorised1, $authorised2 etc?
date_added='" . date("Ymd",time()) . "' where ID= '" . $ID[$x] . "'";
$result = mysql_query($sql);
echo $sql;
#echo "<P>";
echo "<BR>The selected users have now been authorised!<P>";
echo "<a href=\"Javascript:history.go(-1);\">Back to list</a>";
break;
....