liamloveslearning Posted September 29, 2010 Share Posted September 29, 2010 Hi all, I have a table... id | Name | Downloads | 01 | tom | 5 02 | thomas | 2 03 | tommy | 15 I need a button in my page whcih on submit would resent the 'downloads' column so all values are set to 0, Is this possible and how if it is? Thanks for any advice Link to comment https://forums.phpfreaks.com/topic/214748-clear-values-in-mysql-table-column/ Share on other sites More sharing options...
Pikachu2000 Posted September 29, 2010 Share Posted September 29, 2010 You'll probably want to implement some sort of authentication to make sure not just any user can do it, but here's a brief example if( $user == 'authenticated' ) { // <--- obviously pseudo-code if( isset($_POST['reset_count']) ) { $query = "UPDATE `table` SET `downloads` = 0"; mysql_query($query); } } Link to comment https://forums.phpfreaks.com/topic/214748-clear-values-in-mysql-table-column/#findComment-1117278 Share on other sites More sharing options...
liamloveslearning Posted September 29, 2010 Author Share Posted September 29, 2010 Thanks, Ive tried tha using <?php if( isset($_POST['reset_count']) ) { $query = "UPDATE `model_pictures` SET `pdl` = 0"; mysql_query($query); } ?> <form method="post" name="reset_count" > <input type="submit" name="reset_count" value="reset downloads" /> </form> but its not updating, Can you see where im going wrong? Link to comment https://forums.phpfreaks.com/topic/214748-clear-values-in-mysql-table-column/#findComment-1117282 Share on other sites More sharing options...
Pikachu2000 Posted September 29, 2010 Share Posted September 29, 2010 I assume you've included your database connection script somewhere, right? Link to comment https://forums.phpfreaks.com/topic/214748-clear-values-in-mysql-table-column/#findComment-1117299 Share on other sites More sharing options...
liamloveslearning Posted September 29, 2010 Author Share Posted September 29, 2010 Yeah thats included, strange Link to comment https://forums.phpfreaks.com/topic/214748-clear-values-in-mysql-table-column/#findComment-1117339 Share on other sites More sharing options...
liamloveslearning Posted September 29, 2010 Author Share Posted September 29, 2010 I just ran the query in phpmyadmin and it exectued fine so I think maybe im messing up elsewhere Link to comment https://forums.phpfreaks.com/topic/214748-clear-values-in-mysql-table-column/#findComment-1117355 Share on other sites More sharing options...
pengu Posted September 30, 2010 Share Posted September 30, 2010 Perhaps posting your full code may be of assistance. Link to comment https://forums.phpfreaks.com/topic/214748-clear-values-in-mysql-table-column/#findComment-1117436 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.