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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.