Php and MySQL Help

Discussion in 'PHP' started by fazilman, Aug 1, 2009.

  1. #1
    I need a simple help .. i am new in php ..
    i know how to put data from a form through php page to database ..
    but now my problem is if the data is put again it get overwrite..
    So how can i keep the old data and show it as a new data are added ...
    like if i put in the form 10 and next time put 30 it will show me 40 but now it show 30 only

    please help
     
    fazilman, Aug 1, 2009 IP
  2. XDMCoder

    XDMCoder Peon

    Messages:
    50
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Give your script please :rolleyes:
    Dont see the problem. Just det information from DB (SELECT), save it in variable, get information from form and add it to saved variable, update your DB ;)
     
    XDMCoder, Aug 1, 2009 IP
  3. fazilman

    fazilman Peon

    Messages:
    58
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    i dont have script i am making a singel php file for it .. the way you say is sound nice .. i will try if it dont work i will give the php file i make
     
    fazilman, Aug 1, 2009 IP
  4. ezprint2008

    ezprint2008 Well-Known Member

    Messages:
    611
    Likes Received:
    15
    Best Answers:
    2
    Trophy Points:
    140
    Digital Goods:
    1
    #4
    You're probably not adding ID to your database with the auto_update .. so its probably overwriting it.
     
    ezprint2008, Aug 1, 2009 IP
  5. XDMCoder

    XDMCoder Peon

    Messages:
    50
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #5
    For example :p
    <?php
    $con = mysql_connect("localhost","qwerty","qwerty");
    mysql_select_db("yourDB", $con);
    
    $someNumber=$_REQUEST['number']; // number you want to update
    
    $result = mysql_query("SELECT someNumber FROM someTable WHERE id=111");
    while($row = mysql_fetch_array($result))
    {
      $someNumberFromDB = $row['someNumber'];
    }
    $someNumber+=$someNumberFromDB;
    
    mysql_query("UPDATE someTable SET someNumber = $someNumber WHERE id=111");
    mysql_close($con);
    ?>
    PHP:
     
    XDMCoder, Aug 1, 2009 IP