By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,825 Members | 1,456 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,825 IT Pros & Developers. It's quick & easy.

how to call a table data with username

P: 32
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.
Jan 20 '07 #1
Share this Question
Share on Google+
3 Replies


ronverdonk
Expert 2.5K+
P: 4,258
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:
Jan 20 '07 #2

P: 32
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?
Jan 23 '07 #3

ronverdonk
Expert 2.5K+
P: 4,258
Sorry about that. It must, of course, be the stripslashes() function.

Ronald :cool:
Jan 23 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.