This topic is locked
[SOLVED]

 Accessing User data

11/22/2011 1:47:55 AM
PHPRunner General questions
R
Ruined1 author

My user's login in and personal info are all grouped together.
TABLE: vUsers

Columns: Column Type

1 UserID

2 Username

3 Password

4 Email

5 Group

6 Firstname

7 Lastname

8 Joindate

9 PostCount

10 Schoolname

11 Schoolstate

12 Schoolcity

13 Schoolphone

ETC.

ETC.

ETC.
When a user add's a new event I want the information for the event to be automatically pulled from their information
example; Add New>Event
User add's new event. Rather than typing information in like State, First Name, Last Name... This information would be automatically pulled from their information....
For a good example of what I mean, Look Left... The forum pulls my Name, group, posts, and Joindate. That's what I'm trying to do for mine
Any help is greatly appreciated, I've been cracking at it for hours. <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=18390&image=1&table=forumtopics' class='bbc_emoticon' alt=':lol:' />

C
cgphp 11/22/2011

In the "Before record added" event enter the following code:

$rs = CustomQuery("SELECT * FROM vUsers WHERE UserID='".$_SESSION['UserID']."' LIMIT 1");

$record = db_fetch_array($rs);
$values['field_1'] = $record['Firstname'];

$values['field_2'] = $record['Lastname'];

$values['field_3'] = $record['Joindate'];

$values['field_4'] = $record['PostCount'];

...

...

...
R
Ruined1 author 11/22/2011



In the "Before record added" event enter the following code:

$rs = CustomQuery("SELECT * FROM vUsers WHERE UserID='".$_SESSION['UserID']."' LIMIT 1");

$record = db_fetch_array($rs);
$values['field_1'] = $record['Firstname'];

$values['field_2'] = $record['Lastname'];

$values['field_3'] = $record['Joindate'];

$values['field_4'] = $record['PostCount'];

...

...

...



Thank you so much for your response. I added the code as you said and still no cigar. The fields are coming up blank both on the site and the actual values inside the table of the database.
This is definitely correct:

$rs = CustomQuery("SELECT * FROM vUsers WHERE UserID='".$_SESSION['UserID']."' LIMIT 1");

$record = db_fetch_array($rs);


Maybe I am doing something wrong with the assignments?

$values['field_1'] = $record['Firstname'];

$values['field_2'] = $record['Lastname'];

$values['field_3'] = $record['Joindate'];

$values['field_4'] = $record['PostCount'];
Here's what I have under vevents>add page>before record added:



$rs = CustomQuery("SELECT * FROM vUsers WHERE UserID='".$_SESSION['UserID']."' LIMIT 1");

$record = db_fetch_array($rs);
$values['State'] = $record['Schoolstate'];

$values['Denomination'] = $record['Denomination'];

$values['Schoolclass'] = $record['Schoolclass'];

$values['Sportname'] = $record['Sportname'];

$values['City'] = $record['Schoolcity'];

$values['Schoolname'] = $record['Schoolname'];

$values['Teamname'] = $record['Teamname'];

$values['Gender'] = $record['Sportgender'];

$values['Schoolphone'] = $record['Schoolphone'];

$values['Email'] = $record['Email'];
//$record['PostCount']++;
return true;



Did I screw up?

C
cgphp 11/22/2011

Do you want to autofill textboxes when the add page is loaded ? In this case enter the code in the "Process record values" event of Add page (not in the "Before record added" event):

$rs = CustomQuery("SELECT * FROM vUsers WHERE UserID='".$_SESSION['UserID']."' LIMIT 1");

$record = db_fetch_array($rs);
$values['State'] = $record['Schoolstate'];

$values['Denomination'] = $record['Denomination'];

$values['Schoolclass'] = $record['Schoolclass'];

$values['Sportname'] = $record['Sportname'];

$values['City'] = $record['Schoolcity'];

$values['Schoolname'] = $record['Schoolname'];

$values['Teamname'] = $record['Teamname'];

$values['Gender'] = $record['Sportgender'];

$values['Schoolphone'] = $record['Schoolphone'];

$values['Email'] = $record['Email'];


Return statement is not needed.

R
Ruined1 author 11/22/2011



Do you want to autofill textboxes when the add page is loaded ? In this case enter the code in the "Process record values" event of Add page (not in the "Before record added" event):

$rs = CustomQuery("SELECT * FROM vUsers WHERE UserID='".$_SESSION['UserID']."' LIMIT 1");

$record = db_fetch_array($rs);
$values['State'] = $record['Schoolstate'];

$values['Denomination'] = $record['Denomination'];

$values['Schoolclass'] = $record['Schoolclass'];

$values['Sportname'] = $record['Sportname'];

$values['City'] = $record['Schoolcity'];

$values['Schoolname'] = $record['Schoolname'];

$values['Teamname'] = $record['Teamname'];

$values['Gender'] = $record['Sportgender'];

$values['Schoolphone'] = $record['Schoolphone'];

$values['Email'] = $record['Email'];


Return statement is not needed.


I copied the above code exactly as specified to vevents>add page>Process record values.

The fields remain blank still.

C
cgphp 11/22/2011

If Username is the user login field, the query becomes the following:

$rs = CustomQuery("SELECT * FROM vUsers WHERE Username='".$_SESSION['UserID']."' LIMIT 1");

$record = db_fetch_array($rs);
$values['State'] = $record['Schoolstate'];

$values['Denomination'] = $record['Denomination'];

$values['Schoolclass'] = $record['Schoolclass'];

$values['Sportname'] = $record['Sportname'];

$values['City'] = $record['Schoolcity'];

$values['Schoolname'] = $record['Schoolname'];

$values['Teamname'] = $record['Teamname'];

$values['Gender'] = $record['Sportgender'];

$values['Schoolphone'] = $record['Schoolphone'];

$values['Email'] = $record['Email'];
R
Ruined1 author 11/23/2011



If Username is the user login field, the query becomes the following:

$rs = CustomQuery("SELECT * FROM vUsers WHERE Username='".$_SESSION['UserID']."' LIMIT 1");

$record = db_fetch_array($rs);
$values['State'] = $record['Schoolstate'];

$values['Denomination'] = $record['Denomination'];

$values['Schoolclass'] = $record['Schoolclass'];

$values['Sportname'] = $record['Sportname'];

$values['City'] = $record['Schoolcity'];

$values['Schoolname'] = $record['Schoolname'];

$values['Teamname'] = $record['Teamname'];

$values['Gender'] = $record['Sportgender'];

$values['Schoolphone'] = $record['Schoolphone'];

$values['Email'] = $record['Email'];



And that solved the problem. Thank you for all your attention to the matter. You've been a wonderful help!
Problem solved.