php code to show data from a mysql table corresponding to logged in user

Discussion in 'PHP' started by digitalarts, Jul 27, 2009.

  1. #1
    can some one help me with the php code to show data from a mysql table corresponding to currently logged in user.

    I hv created a new table with various filelds want to show for the logged in user. And I am using Wordpress.

    Any help wll be appreciated.
     
    digitalarts, Jul 27, 2009 IP
  2. agilius

    agilius Well-Known Member

    Messages:
    1,021
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    100
    #2
    What part of the process do you don't grasp? r do you simply not know how to do the entire process? Also, let us know how is the table looking.
     
    agilius, Jul 27, 2009 IP
  3. digitalarts

    digitalarts Peon

    Messages:
    105
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Well...I have now partly been able to accomplish the task:

    This is my code:

    <?php $q=explode('¦',end($_COOKIE));
    $login=$q[0];
    $k=mysql_query("select * from user_data where user_login = '$login' limit 1;");
    $r=mysql_fetch_assoc($k); ?>

    <ul><li>
    <?php echo $r[Days worked]; ?><br>
    <?php echo $r[Money earned]; ?><br>
    <?php echo $r[Efficiency]; ?><br>
    <?php echo $r[Completed task]; ?><br>
    </li></ul>

    But the problem now is When the user logs in for the first time it does not show the data. If user logs out and logs in again, it shows the user specific data.

    Table structure:

    I hv a user table with user name and password and another user_data table with user name and data related to each user in various columns.

    Please help me...it has mad me nuts...
     
    digitalarts, Jul 27, 2009 IP
  4. digitalarts

    digitalarts Peon

    Messages:
    105
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I am really saddened to know that in such a big webmasters forum with so many learned people no body has an answwer to my questions.....This is terrible....
     
    digitalarts, Jul 29, 2009 IP