Show COLUMN where ROW=something

Discussion in 'PHP' started by aCebOy, Jun 17, 2013.

  1. #1
    Capture.PNG

    Hello Dear I Want to display 96 in my webpage, please tell me code, please ..

    i want to show like this,

    $crdt = "Show credit where ROW=admin";
    echo $crdt;

    Please tell me about this
     
    Solved! View solution.
    aCebOy, Jun 17, 2013 IP
  2. ActiveFrost

    ActiveFrost Notable Member

    Messages:
    2,072
    Likes Received:
    63
    Best Answers:
    3
    Trophy Points:
    245
    #2
    SELECT credit FROM tablename WHERE username='admin'
    Code (markup):
    Everything else depends on whether you are still using deprecated mysql_* functions or not.

    Note: http://www.w3schools.com/sql/ is waiting for you.
     
    ActiveFrost, Jun 17, 2013 IP
  3. aCebOy

    aCebOy Banned

    Messages:
    68
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    36
    #3
    I type this,

    <?php
     
            mysql_connect("localhost","test","pass") or die(mysql_error());
            mysql_select_db("test") or die(mysql_error());
     
    $lol = SELECT credit FROM dbUsers WHERE username='admin';
     
    echo $lol;
     
    ?>
    PHP:
    This Error show :(

    Parse error: syntax error, unexpected T_STRING in /home/lalaurl/public_html/register/new.php on line 6
     
    aCebOy, Jun 17, 2013 IP
  4. #4
    Are you serious?

    mysql_connect("localhost","root","") or die(mysql_error());
    mysql_select_db("test") or die(mysql_error());
     
    $query = mysql_query("SELECT credit FROM users WHERE username='admin'");
     
    if (mysql_num_rows($query) != 0) {
        while ($row = mysql_fetch_array($query)) {
            echo "Credit: " . $row["credit"];
        }
    } else {
        echo "No data found!";
    }
    PHP:
     
    ActiveFrost, Jun 17, 2013 IP
  5. aCebOy

    aCebOy Banned

    Messages:
    68
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    36
    #5
    Hello Dear if want to put Credit in this,

    $db = new mysqli('localhost','root','','test');
    if ($db->connect_error) {
        die("Connect Error: " .$db->connect_error);
    }
     
    $sql = "UPDATE dbUsers SET credit='??????????' - 1 WHERE username='admin'";
     
    if ($db->query($sql) === FALSE) {
        die("Update failed. Error: " .$db->error);
    } else {
        echo "Success";
    }
    PHP:
     
    aCebOy, Jun 17, 2013 IP