how to call a table data with username

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • anuragpj
    New Member
    • Jan 2007
    • 32

    #1

    how to call a table data with username

    I had created a jogin page and I want that when a user login with its username his data from the table can be fetched .
    how can I store the value of the username field in a variable?

    Suppose my username is 'anurag'. and my table's name is anuragpj then how can i create a variable that contains value which is equalto username+pj that is anuragpj.
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    Originally posted by anuragpj
    I had created a jogin page and I want that when a user login with its username his data from the table can be fetched .
    how can I store the value of the username field in a variable?

    Suppose my username is 'anurag'. and my table's name is anuragpj then how can i create a variable that contains value which is equalto username+pj that is anuragpj.
    You must have stored the username somewhere already, how else could you have used it? Or did you let in in the $_POST array?

    Assuming the latter, you can assign the username to a variable and construct the table name as follows:[php]// save the user name in a variable
    $user_name = strip_slashes($ _POST[ 'user']);
    // construct the table name from the username + pj
    $table_name = $user_name . 'pj';
    // build the SELECT statement
    $sql="SELECT * FROM $table_name ...... ";[/php]
    Ronald :cool:

    Comment

    • anuragpj
      New Member
      • Jan 2007
      • 32

      #3
      Originally posted by ronverdonk
      You must have stored the username somewhere already, how else could you have used it? Or did you let in in the $_POST array?

      Assuming the latter, you can assign the username to a variable and construct the table name as follows:[php]// save the user name in a variable
      $user_name = strip_slashes($ _POST[ 'user']);
      // construct the table name from the username + pj
      $table_name = $user_name . 'pj';
      // build the SELECT statement
      $sql="SELECT * FROM $table_name ...... ";[/php]
      Ronald :cool:
      strip_slashes is not working. can I use some other syntax?
      After storing this variable can I use this variable in some other file?

      Comment

      • ronverdonk
        Recognized Expert Specialist
        • Jul 2006
        • 4259

        #4
        Sorry about that. It must, of course, be the stripslashes() function.

        Ronald :cool:

        Comment

        Working...