MYSQL and PHP re-Numbering elements
<p>The code I have works except for that I am trying to renumber all the items on table "example2" starting from 1. So for example I have 3 elements entered on the table and which contain ("url","number"). number is used to keep track of the elements, so if number 2 is removed i need the remaining two elements to adjust where the first is still 1 and the third becomes 2. Here's what I have:</p>

<pre><code>&lt;?php
 $field1_name = $_POST['Number'];
 $size = 0;
 $con = mysql_connect("localhost", "*****", "*****") or die(mysql_error());
 mysql_select_db("test") or die(mysql_error());
 mysql_query("DELETE FROM example2 WHERE number='$field1_name'") 
 or die(mysql_error()); 
 $result = mysql_query("SELECT COUNT(*) FROM example2");
 $row = mysql_fetch_assoc($result);
 $size = $row['COUNT(*)'];
 $l = 1; while ($l &lt;= $size) { $temp = "${"example2_$l"}"; 
 mysql_query("UPDATE example2                                              
 SET number = '$temp' WHERE number = $l"); mysql_query($query)or 
 die(mysql_error());$temp++; $l++;};

 mysql_close($con);
 ?&gt;
  &lt;script language="javascript" type="text/javascript"&gt;
    window.location = 'table.html';
  &lt;/script&gt;
</code></pre>
