variables

Discussion in 'PHP' started by demons-halo, Sep 25, 2009.

  1. #1
    SELECT * FROM `users` WHERE 1`userid``money`

    i want to make the 'money' field into a variable, how can i code this? also i want it to come from a specific user which is specified by a variable in the userid field

    thanks

    dH
     
    demons-halo, Sep 25, 2009 IP
  2. ezprint2008

    ezprint2008 Well-Known Member

    Messages:
    611
    Likes Received:
    15
    Best Answers:
    2
    Trophy Points:
    140
    Digital Goods:
    1
    #2
    that code you already have is wrong, and thats SQL stuff. :D

    You'd have to make your SQL code so that it works, and then it would look somethin like userid = "1" ;
    then once you pulled everything from that record (because youre using a wildcard * ) then you should have a data field called money in your database. then grab it with something like $row['money']
    since the wildcard will pull it into your PHP. But you have to learn PHP and SQL first.. because seeing by your code example, you're just now barely started.
     
    ezprint2008, Sep 25, 2009 IP
  3. demons-halo

    demons-halo Active Member

    Messages:
    243
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    55
    #3
    right that makes sense, and im making use of the experienced programmers here :D im stuck and just need help lol
     
    demons-halo, Sep 25, 2009 IP
  4. newgenservices

    newgenservices Well-Known Member

    Messages:
    862
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    105
    Digital Goods:
    1
    #4
    I am not sure what you mean from above. May be you can try something like this.

    
    <?php
    $uid = "1"; // Assuming we got this from session or somewhere else.
    $money = "10" // Assuming we get this value from $_POST or somewhere else.
    
    $query = "SELECT * FROM `users` WHERE userid = '".$uid."' AND money = '".$money."'";
    $result = mysql_query($query);
    
    ?>
    
    Code (markup):
     
    newgenservices, Sep 25, 2009 IP