News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Pulling data from database

Started by PrizeLive.com, July 14, 2006, 09:00:05 AM

Previous topic - Next topic

PrizeLive.com

Ok I made a few new fields in the database.. Let's called them x and y... They are setup with the same variables and attributes as the posts field.

Anyway.. I need a way to access these fields and display them on the users' profile page... How can I do this?  I also need the code setup so when an admin views their profile page, the admin sees the users' stats instead of his own...

For now, these fields (x and y) will be updated in the database...

The next step would be creating something similar to the karma mod to be able to edit it..

Thanks!

I will pay for help!!
Get Paid Instantly via PayPal (or other options) at PrizeLive.com!

vbgamer45

#1
Quick and dirty example


//A simple MySQL query that gets the members name for the first member.
$request = db_query("SELECT memberName FROM {$db_prefix}members ID_MEMBER = 1 ", __FILE__, __LINE__);
//Fetchs the information
$row = mysql_fetch_row($request);
//Display the information on the page
echo $row['memberName'];


Now in your case you just want to modify the profile.template.php for the theme you are using then add the mysql query to the place that you want it to show.
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

PrizeLive.com

Ok cool.....

but what data does that query return?  It looks like it just returns the memberName...

what about this part -- "SELECT memberName FROM {$db_prefix}lmembers ID_MEMBER = 1"

wouldnt that just return the memberName where id_member = 1 ?

i want it to return the data in a certain column (x) where id_member = yourprofile..

for example, if i log in as a regular user, i'd want to see this data on a certain page...

however, if i login as admin and view my page, i'd see my info but if i view another members page, id be able to see theirs......

can you help with that?
Get Paid Instantly via PayPal (or other options) at PrizeLive.com!

vbgamer45

Yeah this query just returns the member name for the first member.

There is a lot of background that goes into this.
While I am here this maybe useful in the future.
The current member ID that is logged is stored in the $ID_MEMBER variable.
If you want to use $ID_MEMBER in a function you need to make sure it is in the globals section of that function example
function somefunctionname()
{
globals $ID_MEMBER;

//Other code goes below
}

This basicly says that $ID_MEMBER is a global varible and you are making it aviable for local use in that function


When you edit the profile page basicly all you need to do is edit the one query when it is getting data from the members table. And just add the fields that you want to retrive
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

PrizeLive.com

Thanks a lot......

I'm willing to pay for help for other things as well if you are interested...
Get Paid Instantly via PayPal (or other options) at PrizeLive.com!

Advertisement: