Go Back   WarriorForum - Internet Marketing Forums > Warrior Support Forums > Programming Talk

Reply
 
LinkBack Thread Tools
Old 08-23-2009, 06:04 PM   #1
Old, tired and ugly coot
War Room Member
 
Kirk Ward's Avatar
 
Join Date: May 2006
Location: Ellijay, GA, USA. (Talk about being in the woods!)
Posts: 1,112
Thanks: 103
Thanked 33 Times in 27 Posts
Social Networking View Member's Twitter Profile 
Default Need help getting a piece of data from the Wordpress database?

I want to extract a piece of data for the logged in user from the Wordpress database, so that I can use it as a variable in another script. The data is the value in a key:value pair in the meta_value field.

Retrieving data from the Wordpress database seems confusing as all get out to me. I saw the $wpdb function, but after that I get lost.

Anyone here what can help with the SQL for that? I use MySQL on a Linux server.

Many thanks in advance,
Kirk

Thought For The Day.

My thoughts are like lightning. One brilliant flash, and then they're gone.
Kirk Ward is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-23-2009, 06:21 PM   #2
SEO Expert Warrior
War Room Member
 
Joshua Kwentoh's Avatar
 
Join Date: Dec 2008
Location: United Kingdom / USA
Posts: 34
Thanks: 5
Thanked 24 Times in 5 Posts
Social Networking View Member's Twitter Profile 
Contact Info
Send a message via Yahoo to Joshua Kwentoh Send a message via Skype™ to Joshua Kwentoh
Default Re: Need help getting a piece of data from the Wordpress database?

Had the same problem and will be happy for someone to share info how its done
Joshua Kwentoh is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-23-2009, 06:31 PM   #3
HyperActive Warrior
War Room Member
 
john_kennedy's Avatar
 
Join Date: Dec 2002
Location: Mobile, AL , USA.
Posts: 273
Thanks: 65
Thanked 41 Times in 37 Posts
Default Re: Need help getting a piece of data from the Wordpress database?

Did you read the information on this page:

Function Reference/wpdb Class WordPress Codex

Spells it out for you pretty well.

John
john_kennedy is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-24-2009, 12:14 AM   #4
Warrior Member
 
Join Date: Aug 2009
Posts: 5
Thanks: 0
Thanked 1 Time in 1 Post
Default Re: Need help getting a piece of data from the Wordpress database?

I think you want to query data directly from wordpress database.
The table containing user information is wp_users. You can read schema from link gave by john_kennedy.

After login and connect to wp database. I think you can use this SQL command.
"select * from wp_users"
jumboa7 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-24-2009, 07:14 AM   #5
Web Developer, IT Support
War Room Member
 
n7 Studios's Avatar
 
Join Date: Dec 2008
Location: Birmingham, UK
Posts: 359
Thanks: 7
Thanked 50 Times in 45 Posts
Social Networking View Member's FaceBook Profile  View Member's Twitter Profile 
Contact Info
Send a message via Skype™ to n7 Studios
Default Re: Need help getting a piece of data from the Wordpress database?

Assuming you've stored the user meta data in the correct way (i.e. it's in the wp_usermeta table), you can just use:

PHP Code:
get_usermeta(userID'metakey'); 
See Function Reference/get usermeta WordPress Codex for a full function reference.

n7 Studios is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-24-2009, 08:18 AM   #6
Old, tired and ugly coot
War Room Member
 
Kirk Ward's Avatar
 
Join Date: May 2006
Location: Ellijay, GA, USA. (Talk about being in the woods!)
Posts: 1,112
Thanks: 103
Thanked 33 Times in 27 Posts
Social Networking View Member's Twitter Profile 
Default Re: Need help getting a piece of data from the Wordpress database?

Many thanks to all ... but it seems that old retired bean counters have mental blocks from all the numbers they read over the years ... meaning, I still have problems.

I had previously tried reading the function reference for the wpdb class (which I called the $wpdb function in my original post), but it wasn't basic or simple enough for me. My understanding of code is limited to cut and paste. (That's what happens after thrity years as an accountant, you get stupidiated.)

Based on Tim's (N7) line of code, I tried
Code:
<?php
 = get_usermeta(userID, 'metakey'); 
echo  . "n";
?>
in the html of a wordpress page and got nothing.

edit: seems the $mydata and the \ before the n disappeared from the code block ... sorry.

My user_id value is 1
My meta_key value is dr_extra_fields
The meta_value field for that record contains ...
Code:
s:203:"a:6:{s:10:"dr_address";s:11:"PO Box 1787";s:7:"dr_city";s:7:"Ellijay";
s:8:"dr_state";s:2:"GA";s:6:"dr_zip";s:5:"30540";s:8:"dr_phone";
s:14:"(706) 698-5475";s:10:"dr_bp_name";s:20:"Kirk Ward Accounting";}";
My goal is to pull any one of the values from those key:value pairs and use it on a page for the logged in user.

Any further ideas?

Thanks in advance.
Kirk

Thought For The Day.

My thoughts are like lightning. One brilliant flash, and then they're gone.
Kirk Ward is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

  WarriorForum - Internet Marketing Forums > Warrior Support Forums > Programming Talk

Tags
data, database, piece, wordpress

Thread Tools

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



All times are GMT -6. The time now is 09:41 AM.