Jump to content

Need help with nested queries


rtchin

Recommended Posts

Hi, i'm trying to resort after deleting and item.  when i echo the nested sql statement it looks right, however, when i go back to the database, the sort is all wrong.  what happens is it always sorts the first two records with 0..  should be, 0,1,2,3,etc.

so may table is always

id namesort

1 aaa0

2 bbb0

3 ccc2

 


$sql="DELETE FROM categories WHERE id = $_GET[id]";


	         if (!mysql_query($sql,$con))
  			 {
				 	 die('Error: ' . mysql_error());
  			 }
		$result = mysql_query("SELECT * FROM categories order by sort");

		while($row = mysql_fetch_array($result))
  			 {
			   
			   
                                   mysql_query("update categories set sort = $rank where id = $row[id]");
			   $rank++;
			   //echo $update;


			}

 

 

Link to comment
https://forums.phpfreaks.com/topic/101006-need-help-with-nested-queries/
Share on other sites

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.