JonnySnip3r Posted May 20, 2010 Share Posted May 20, 2010 Hey guys hope someone can help. Im fairly new to PHP and i was wondering if someone can point me the right direction. I'm creating a website and i have gotten to the point where im listing my members and when i delete them by id it has this: id name email etc... 1 John john@lol.com 2 Will lol@lol.com 3 Carl gog@lol.com say i delete Carl 3 has gone but how do i shift rows down? here is my delete phpcode. $id = $_POST['id']; $mysqli = new mysqli('localhost', 'name', 'pass', 'db') or die ("There was a problem connecting to your database!"); $stmt = $mysqli->prepare('DELETE FROM users WHERE id=?'); $stmt->bind_param('i', $id); $stmt->execute(); $stmt->close(); Hope someone can help, Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/202451-php-shift-rows-up-when-deleted/ Share on other sites More sharing options...
trq Posted May 21, 2010 Share Posted May 21, 2010 Why would you want to do this? Your id column should be auto incrementing and should be left under the control of the database. There is no logical reason to do otherwise. Quote Link to comment https://forums.phpfreaks.com/topic/202451-php-shift-rows-up-when-deleted/#findComment-1061433 Share on other sites More sharing options...
JonnySnip3r Posted May 21, 2010 Author Share Posted May 21, 2010 so its normal for databases to have skipped values like 1, 2, 4, 8, 9, 10, 12 etc? But thanks for the reply dude! Quote Link to comment https://forums.phpfreaks.com/topic/202451-php-shift-rows-up-when-deleted/#findComment-1061548 Share on other sites More sharing options...
jdavidbakr Posted May 21, 2010 Share Posted May 21, 2010 so its normal for databases to have skipped values like 1, 2, 4, 8, 9, 10, 12 etc? But thanks for the reply dude! Yes, the ID field's purpose is to uniquely identify the row and should never change. It's very common for the autoincrement ID field to have all kinds of holes in it, just like your checkbook if you've ever voided a check. If you want to present to the user an order, then you can have a separate column for that, or just generate those numbers as you build the table. Quote Link to comment https://forums.phpfreaks.com/topic/202451-php-shift-rows-up-when-deleted/#findComment-1061645 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.