Hi everyone,
I've got a bit of a problem with a query I am trying to run on a MySQL Database through PHP... below is the code:
[COLOR=Red]function deleterow($documentid,$rowid) {
$getorder = mysql_query("select * from documentrows where documentid = '$documentid' and rowid = $rowid");
$resultorder = mysql_fetch_array($getorder);
$currentroworder = $resultorder["roworder"];
mysql_query("delete from documentcols where documentid = '$documentid' and rowparent = $rowid");
mysql_query("delete from documentrows where documentid = '$documentid' and rowid = $rowid");
mysql_query("delete from documentcontent where documentid = '$documentid' and rowparent = $rowid");
$getnext = mysql_query("select * from documentrows where documentid = '$documentid' and roworder > $currentroworder");
while ($resultrows = mysql_fetch_array($getnext)) {
$resultroworder = $resultrows["roworder"];
$neworder = $resultroworder - 1;
$resultrowid = $resultrows["rowid"];
$query = "update documentrows set roworder = $neworder where documentid = '$documentid' and rowid = $resultrowid";
[COLOR=DarkGreen]mysql_query($query)[/COLOR] or die("Failed Query");
echo($query);echo("<br>");
}
}
[/COLOR]
Now the query that isn't running is the one down the bottom $query... i have it echoing to the screen at the moment so that I can see the query that is output... if i cut and paste this query directly into a MySQL database, it runs fine, if I run the function manually... it runs fine... it is only when I run it as part of the following function that the particular query falls over. Everything else in the function works pefectly
function massdelete($documentid) {
$getrows = mysql_query("select * from documentrows where documentid = '$documentid'");
while($resultrows = mysql_fetch_array($getrows)) {
$rowid = $resultrows["rowid"];
$fieldname = "massdelete$rowid";
if ($_POST[$fieldname] == "on") {
deleterow($documentid,$rowid);
}
}
}
[/COLOR]
Does anyone have any ideas ??