mforan Posted November 30, 2006 Share Posted November 30, 2006 hi there, how would i go about making a php script that resets all the information in the database to the default values?this would exclude there username, email address etc....is this at all possible? Link to comment https://forums.phpfreaks.com/topic/29038-clear-database-but-leave-user-info/ Share on other sites More sharing options...
trq Posted November 30, 2006 Share Posted November 30, 2006 The easiest way would probably be to copy any data you want to keep into a temp table, drop the current table, then copy the saved data into a new table.My question is Why? Link to comment https://forums.phpfreaks.com/topic/29038-clear-database-but-leave-user-info/#findComment-133050 Share on other sites More sharing options...
Zane Posted November 30, 2006 Share Posted November 30, 2006 explain a little morewhat are the default valueswhich [b]information[/b] in the databaseand most likely the answer to this is an SQL statementnot a PHP script, although you can use PHP to do it Link to comment https://forums.phpfreaks.com/topic/29038-clear-database-but-leave-user-info/#findComment-133052 Share on other sites More sharing options...
marcus Posted November 30, 2006 Share Posted November 30, 2006 You could just do[code]$sql = "UPDATE `users` SET `field1` =0, `field2` =0";$res = mysql_query($sql) or die(mysql_error());[/code] Link to comment https://forums.phpfreaks.com/topic/29038-clear-database-but-leave-user-info/#findComment-133053 Share on other sites More sharing options...
mforan Posted November 30, 2006 Author Share Posted November 30, 2006 well rather than remove all the user data i want to keep there username and password. the other material i can reset to 0 or to the default values.basically its a game that resets every so oftern, and i dont want to remove there username information everytime i do this reset. this is so that even after the reset the can log in to the same user, but everyone starts at a default level once more.is that any help guys? Link to comment https://forums.phpfreaks.com/topic/29038-clear-database-but-leave-user-info/#findComment-133056 Share on other sites More sharing options...
marcus Posted November 30, 2006 Share Posted November 30, 2006 You can do thatby updating the rows[code]$sql = "UPDATE users SET `level` =1, `points` =250";$res = mysql_query($sql) or die(mysql_error());[/code] Link to comment https://forums.phpfreaks.com/topic/29038-clear-database-but-leave-user-info/#findComment-133058 Share on other sites More sharing options...
mforan Posted November 30, 2006 Author Share Posted November 30, 2006 is that just for 1? or the entire list... Link to comment https://forums.phpfreaks.com/topic/29038-clear-database-but-leave-user-info/#findComment-133059 Share on other sites More sharing options...
marcus Posted November 30, 2006 Share Posted November 30, 2006 that would be the entire list Link to comment https://forums.phpfreaks.com/topic/29038-clear-database-but-leave-user-info/#findComment-133065 Share on other sites More sharing options...
mforan Posted December 1, 2006 Author Share Posted December 1, 2006 thanks, this worked a treat! ;D Link to comment https://forums.phpfreaks.com/topic/29038-clear-database-but-leave-user-info/#findComment-133092 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.