PHP + MySQL HELP!

Discussion in 'PHP' started by nVus, Oct 17, 2009.

  1. #1
    Hello,

    I would like to have a link in my admin back-end to "reset a value to 0 in a mysql database".

    For example:

    In "xyz_users" a value has "29" and so I would like to reset that specific value with a link in the admin section.

    How can I go about doing so?

    Thank you!
     
    nVus, Oct 17, 2009 IP
  2. Luke Carrier

    Luke Carrier Peon

    Messages:
    19
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Do you mean the AUTO_INCREMENT value? Is xyz_users a table or a row? If not, what would you like to achieve?
     
    Luke Carrier, Oct 18, 2009 IP
  3. JAY6390

    JAY6390 Peon

    Messages:
    918
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #3
    If it's the auto increment it's not possible wiithout truncating the whole table. If the 29 is just a normal field, but still unique, you can do a simlpe query of
    UPDATE `xyz_table` WHERE `column_name` = '29'
     
    JAY6390, Oct 18, 2009 IP
  4. dweebsonduty

    dweebsonduty Active Member

    Messages:
    131
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    71
    Digital Goods:
    1
    #4
    
    if ($row["column"] >= 29)
    {
    echo $link
    }
    
    PHP:
    You can use a GET to initiate the update or you can write an ajax function to do it.
     
    dweebsonduty, Oct 19, 2009 IP
  5. orionoreo

    orionoreo Peon

    Messages:
    145
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    just have an update user button

    
    <?php
    
    //Reseting User Value
    if (isset($_POST['reset_user'])) {
    	$user_name = 'xyz_users';
        
        //Resetting
        $update_user = "UPDATE user_table SET specific_value='0' WHERE username='$user_name'";
        mysql_query($update_user) or die ('Can\'t Update');
    }
    
    ?>
    
    <form action="" method="post">
    	<input name="reset_user" type="submit" value="Reset Value" />
    </form>
    
    
    
    
    PHP:
     
    orionoreo, Oct 19, 2009 IP