www.webdeveloper.com
Results 1 to 3 of 3

Thread: Getting values from table and storing it to variable.. PHP & MySQL

Hybrid View

  1. #1
    Join Date
    Oct 2012
    Location
    Gujarat, India.
    Posts
    35

    Getting values from table and storing it to variable.. PHP & MySQL

    I have one table which contains user_id, username, password and points columns. It is in table named "users" in database named 'admin_users".

    When one successfully login, the following is set...
    PHP Code:
    $username $_SESSION['username']; 
    now, i want to store $points variable equal to points of user named "$username" , how to do it. Means (i think i wasn't clear what i wanted to say), i want to get value of column "points" from table users where username = $username....

    I am totally confused, hope you help.

  2. #2
    Join Date
    Feb 2012
    Location
    Tallahassee, FL
    Posts
    280
    Something like this:
    PHP Code:
    $query "SELECT * FROM table WHERE username = 'someuser'";
    $exe mysql_query($query);
    while(
    $row mysql_fetch_array($exe)){
    foreach(
    $row as $r => $v){
    /* $r is the column name and $v is the value */
    $_SESSION[$r] = $v;
    }


  3. #3
    Join Date
    Oct 2012
    Location
    Gujarat, India.
    Posts
    35

    Cool Same...

    P.S. : COULD ANYONE BELIEVE THIS? I ANSWERED TO MY OWN QUESTION..........

    Thanks it worked....

    Well i now have another task, I want to update those points how to it?

    I just want to know how to update that table and get value back?
    Last edited by deepode; 10-21-2012 at 12:10 PM. Reason: I posted answer to my own question

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles