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 Quote Link to comment 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); } } Quote Link to comment 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? Quote Link to comment 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? Quote Link to comment Share on other sites More sharing options...
liamloveslearning Posted September 29, 2010 Author Share Posted September 29, 2010 Yeah thats included, strange Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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.