Jump to content

Clear values in MySQL table column


liamloveslearning

Recommended Posts

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

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);

    }

}

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.