Jump to content

Deleting a row and renaming the remaining rows BOGGLE


Stavros

Recommended Posts

Hello I need some help here as I cant see where I'm going wrong with my code???

 

I have say 5 rows in a table and if I delete row 3, row 3 is deleted and rows 4 & 5 are now renamed to rows 3 & 4. make sense?

 

BUT when I try to delete row 1 I end up with two row 2's.

 

Any help appreciated...

 

 

//Find the amount of LineItems and delete

$CheckItemDelete=$_GET["LineItemDelete"];

 

 

//Find quote number and show frames to edit

$result = mysql_query("SELECT * FROM Table WHERE ID='1'") or die(mysql_error()); 

($row = mysql_fetch_array($result));

$QuoteCheck = ($row['QuoteCheck']);

 

mysql_query("DELETE FROM Table WHERE LineItems='$CheckItemDelete' && QuoteNum='$QuoteCheck'");

 

mysql_query("DELETE FROM Table WHERE LineItems='$CheckItemDelete' && QuoteNum='$QuoteCheck'");

 

mysql_query("DELETE FROM Table WHERE LineItems='$CheckItemDelete' && QuoteNum='$QuoteCheck'");

 

 

 

$result3 = mysql_query("SELECT * FROM Table WHERE QuoteNum='$QuoteCheck' ORDER BY LineItems ASC") or die(mysql_error()); 

($row3 = mysql_fetch_array($result3));

 

while($row3 = mysql_fetch_array($result3))

{

if (($row3['LineItems']) > $CheckItemDelete){

$LineItemCountAdjust = ($row3['LineItems']) - 1;

$LineItemCount = ($row3['LineItems']);

 

rename("Folder/$QuoteCheck$LineItemCount.png", "Folder/$QuoteCheck$LineItemCountAdjust.png");

 

echo "$LineItemCountAdjust";

echo "$LineItemCount";

$result = mysql_query("UPDATE Table SET LineItems ='$LineItemCountAdjust' WHERE LineItems='$LineItemCount' && QuoteNum='$QuoteCheck'")

or die(mysql_error());

}

 

}

 

$MyDir = "Folder/";

$MyExt = ".png";

 

unlink($MyDir.$QuoteCheck.$CheckItemDelete.$MyExt);

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.