Jump to content

Can't delete multi records from DB with PHP


Skylight_lady

Recommended Posts

Hi Guys, How come i am unable to delete a record with the same id from multi records with the following php code?

$rid = "SELECT month_ID FROM monthA WHERE userID = '".$_POST['userID']."' AND thisMonth = '".$_POST['month']."' AND thisYear = '".$_POST['year']."'";
		$rid_month = mysql_query($rid);
            $row = mysql_fetch_array($rid_month);
            $month_ID = $row["month_ID"];

		$rid = "SELECT * FROM monthB WHERE month_ID = '$month_ID'";
            $rid_month = mysql_query($rid);
		$row = mysql_fetch_array($add_member);
            while ($row = mysql_fetch_array($rid_month)) {
			$month_ID = $row["month_ID"];
			$rid = "DELETE FROM monthBB WHERE month_ID = '$month_ID' ";
			$result =  mysql_query($rid);
		}
		$rid = "SELECT * FROM monthC WHERE month_ID = '$month_ID' ";
            $rid_month = mysql_query($rid);
            while ($row = mysql_fetch_array($rid_month)) {
			$month_ID = $row["month_ID"];
			$rid = "DELETE FROM monthCC WHERE month_ID = '$month_ID' ";
			$result =  mysql_query($rid);
		}
		$rid = "DELETE FROM monthA WHERE month_ID = '$month_ID' ";
		$result =  mysql_query($rid);

 

I have tried a number of ways without any luck. How ever if i use this code?

mysql_query("DELETE FROM monthA WHERE month_ID = '$month_ID'");

It allows me to delete one row from one table only. Please advise

Sorry, i was changing the code for your view and changed all $add_member to $rid_month. missed one there.

 

I'm actually redirecting the page after that final sql statement. It's not shown in the code. I'll disable the redirect and check for errors.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.