Reading Individual Record From Mysql

Hi
i have set up a blog based on wordpress. I want to add user specific data which is read-only for the users. So i created two fields : user_survey and user_survey_complete in wp_users tables
Now I want the users to be able to view the data under these colums but only for their own accounts . I don’t know how to use session function so I created a page which asks for the user_id and user_pass and returns the data under field user_survey and user_survey_complete
Instead of returning the data in user_survey and user_survey_complete , it just returns the heading user_survey and user_survey_complete

the code which asks for data is :

[CODE]

Username
Password
[/CODE]

The code which I used to display the data

[CODE]MySQL Table Viewer

<?php $db_host = 'localhost'; $db_user = 'userid'; $db_pwd = 'password'; $database = 'wordpress_management'; $table = 'wp_users'; $user_id = trim(mysql_real_escape_string($_POST["user_id"])); $user_pass = trim(mysql_real_escape_string($_POST["user_pass"])); if (!mysql_connect($db_host, $db_user, $db_pwd)) die("Can't connect to database"); if (!mysql_select_db($database)) die("Can't select database"); // sending query $result = mysql_query("SELECT user_survey_link, user_survey_compelete FROM {$table} WHERE {$user_id}=user_login AND {$user_pass}=user_pass "); if (!$result) { die("Query to show fields from table failed"); } $fields_num = mysql_num_fields($result); echo "

Table: {$table}

"; echo ""; // printing table headers for($i=0; $i<$fields_num; $i++) { $field = mysql_fetch_field($result); echo ""; } echo "\n"; // printing table rows while($row = mysql_fetch_row($result)) { echo ""; // $row is array... foreach( .. ) puts every element // of $row to $cell variable foreach($row as $cell) echo ""; echo "\n"; } mysql_free_result($result); ?> [/CODE]

Please help me in displaying the data under the fields.
If someone know wordpress then please help me use session instead of asking for userid and pass
I am a noob and not good at php so please provide the solution in detail
Thanks a lot :slight_smile:

{$field->name}
$cell

Try adding this to the top of your script (first line) and see if you can access the existing session.

[php]
session_start();
print_r($_SESSION);
[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service