Advertisement
secondcoming

resequence construction.id

Jun 5th, 2016
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.54 KB | None | 0 0
  1. <?php
  2.  
  3. $serverIP = '127.0.0.1';
  4. $serverUser = 'dbuser';
  5. $serverPass = 'dbpass';
  6. $serverDB = 'exile';
  7. $ServerPort = '3306';
  8.  
  9.  
  10. $sql = "SELECT * FROM construction ORDER BY ID";
  11. $result = mysqli_query($db_local, $sql);
  12. $new_id = 1;
  13.  
  14. while(row = mysqli_fetch_object($result))
  15. {
  16.     $id                 = $row->id;
  17.     $last_updated_at    = $row->last_updated_at;
  18.     $sql2 = "UPDATE construction SET id = '$new_id', last_updated_at = '$last_updated_at' WHERE id = '$id'";
  19.     echo "<hr>$sql2<hr>";
  20.     $result2 = mysqli_query($db_local, $sql2);
  21.     $id = $id +1;
  22. }
  23. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement