Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Retieving Data From MySQL
Old 05-30-2005, 12:42 AM Retieving Data From MySQL
Experienced Talker

Posts: 32
Name: Rae
Location: Severn, MD USA
Trades: 0
Alright, I've been working on this profile system thing for (no lie) almost a year... currently 3 days with barely any sleep.. I have the information collecting and storing part DONE. Now, my issue is with retrieving and displaying the data from the two databases in the user's profile. There are 2 database tables: test_users and test_profile.

Test_user contains:
id
login
password
display_name
pass_hint
email
tmp_email
active

Test_profile contains:
id
users_id
language
name
age
sex
country
homepage
interests
pic
user_1
user_2
user_3
user_4
user_5
user_6
user_7
last_change

Now, I'm having trouble mainly with the class that handles session creation and login info, I don't know what all is stored in the session (this isn't my script and I'm not familiar with classes). This is the link to a textbox that contains the access_user_class and the profile template. Oh yeah, I also don't know how to properly code the array. What I need is to fetch all the data from a row (info belonging to the user who is currently logged in) and assign each piece of data that is retrieved a variable to be called later by the profile. What I do NOT want is to pull the data from the table and then echo or print it out right after the query. This is probably really confusing, and I'm sure the answer is quite easy, but again, 3 days(-sleep)+(3 hours of searching this forum)=- energy. Thanks in advance!
SunBlind is offline
Reply With Quote
View Public Profile Visit SunBlind's homepage!
 
 
Register now for full access!
Old 05-30-2005, 08:13 AM
Uche's Avatar
Extreme Talker

Posts: 174
Location: Nigeria/Lagos
Trades: 0
So what do u want now.. Elaborate more !
__________________
Life is just lyke a school where everybody goes to learn one or two thing. the more u school, the more u learn more about school..The more we live our lifes.. the more we learn more about life.

Please login or register to view this content. Registration is FREE
Uche is offline
Reply With Quote
View Public Profile Visit Uche's homepage!
 
Old 05-30-2005, 09:33 PM
Experienced Talker

Posts: 32
Name: Rae
Location: Severn, MD USA
Trades: 0
I just needed the data that's pulled from the database to be stored in variables, but I figured it out now My new issue is figuring out how to display the profile information to an outside user (so far,viewers can only see their profile when they're logged in to edit it)
SunBlind is offline
Reply With Quote
View Public Profile Visit SunBlind's homepage!
 
Old 05-30-2005, 11:45 PM
skima's Avatar
Average Talker

Posts: 15
Location: Lagos, Nigeria
Trades: 0
if you know better how to use cookie u may use it in association with session.
take this example :
<?
include "connect.php";

// retrieve data submitted *mainly login and password needed for now

$log=$_POST['login'];
$pwd=$_POST['pwd'];


//our sql query below
$sql=mysql_query(" select * from Test_user where login='$log' and password='$pwd' ");

//now lets validate the entry if its in the database

if (mysql_num_rows($sql))==0){

echo"You data is not found";

exit();
}
// if the user is found then we can continue our script.

?>
__________________
...thinking positively, providing solutions. live is good.
Please login or register to view this content. Registration is FREE
skima is offline
Reply With Quote
View Public Profile Visit skima's homepage!
 
Old 05-30-2005, 11:51 PM
skima's Avatar
Average Talker

Posts: 15
Location: Lagos, Nigeria
Trades: 0
i recommend dat you use just a single database with two tables. for connection purpose. ill post solution now.
__________________
...thinking positively, providing solutions. live is good.
Please login or register to view this content. Registration is FREE
skima is offline
Reply With Quote
View Public Profile Visit skima's homepage!
 
Old 05-30-2005, 11:58 PM
skima's Avatar
Average Talker

Posts: 15
Location: Lagos, Nigeria
Trades: 0
continuation of the above script:
<?
// if the user is found then we can continue our script.

//below fetch the data from the database and store in variables.
//remember. i use column name in the variable also, for memorization purpose.
while($fet=mysql_fetch_array($sql)){

$id=$fet['id'];
$login=$fet['login'];
$password=$fet['password'];
$display_name=$fet['display_name'];
$pass_hint=$fet['pass_hint'];
$email=$fet['email'];
$tmp_email=$fet['tmp_email'];
$active=$fet['active'];

//You can now echo out the data

//making sure u close it with this brace }

echo $id ;
//etc
?>


***session in the next post
__________________
...thinking positively, providing solutions. live is good.
Please login or register to view this content. Registration is FREE
skima is offline
Reply With Quote
View Public Profile Visit skima's homepage!
 
Old 05-31-2005, 12:16 AM
skima's Avatar
Average Talker

Posts: 15
Location: Lagos, Nigeria
Trades: 0
you can conbine it with the two scripts above.

<?
$id=$fet2['id'];
$users_id=$fet2['users_id'];
$language=$fet2['language'];
$name=$fet2['name'];
$age=$fet2['age'];
$sex=$fet2['sex'];
$country=$fet2['country'];
$homepage=$fet2['homepage'];
$interests=$fet2['interest'];
$pic=$fet2['pic'];
$user_1=$fet2['user_1'];
$user_2=$fet2['user_2'];
$user_3=$fet2['user_3'];
$user_4=$fet2['user_4'];
$user_5=$fet2['user_5'];
$user_6=$fet2['user_6'];
$user_7=$fet2['user_7'];
$last_change=$fet2['last_change'];

//having stored in variables now
//you can do anything with these values

//remember that this only bring out data for the logged in person

//also, if you are to display pic remember you have to store it in a special way //different from others


?>

Hope it helps.
__________________
...thinking positively, providing solutions. live is good.
Please login or register to view this content. Registration is FREE
skima is offline
Reply With Quote
View Public Profile Visit skima's homepage!
 
Old 05-31-2005, 12:42 AM
skima's Avatar
Average Talker

Posts: 15
Location: Lagos, Nigeria
Trades: 0
if any probs . do let me know.
__________________
...thinking positively, providing solutions. live is good.
Please login or register to view this content. Registration is FREE
skima is offline
Reply With Quote
View Public Profile Visit skima's homepage!
 
Reply     « Reply to Retieving Data From MySQL
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.27813 seconds with 12 queries