Go Back   WarriorForum - Internet Marketing Forums > Warrior Support Forums > Programming Talk
Register Blogs FAQ Social Groups CalendarHelp Desk

Reply
 
LinkBack Thread Tools
Old 08-23-2009, 07:04 PM   #1
Ungrateful S.O.B.
War Room Member
 
Kirk Ward's Avatar
 
Join Date: May 2006
Location: Ellijay, GA, USA. (Talk about being in the woods!)
Posts: 1,393
Thanks: 253
Thanked 57 Times in 45 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

"We are not here to sell a parcel of boilers and vats, but the potentiality of growing rich beyond the dreams of avarice."

Dr. Samuel Johnson (Presiding at the sale of Thrales brewery, London, 1781)
Kirk Ward is offline   Reply With Quote
Old 08-23-2009, 07:21 PM   #2
I LOVE JV
War Room Member
 
Joshua Kwentoh's Avatar
 
Join Date: Dec 2008
Location: United Kingdom / USA
Posts: 184
Thanks: 154
Thanked 73 Times in 33 Posts
Contact Info
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   Reply With Quote
Old 08-23-2009, 07:31 PM   #3
HyperActive Warrior
War Room Member
 
john_kennedy's Avatar
 
Join Date: Dec 2002
Location: Mobile, AL , USA.
Posts: 302
Thanks: 75
Thanked 49 Times in 44 Posts
Social Networking View Member's FaceBook Profile 
Contact Info
Send a message via Skype™ to john_kennedy
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   Reply With Quote
Old 08-24-2009, 01: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   Reply With Quote
Old 08-24-2009, 08:14 AM   #5
Web Developer, IT Support
War Room Member
 
n7 Studios's Avatar
 
Join Date: Dec 2008
Location: Birmingham, UK
Posts: 513
Thanks: 10
Thanked 77 Times in 65 Posts
Social Networking View Member's FaceBook Profile  View Member's Twitter Profile 
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 online now   Reply With Quote
Old 08-24-2009, 09:18 AM   #6
Ungrateful S.O.B.
War Room Member
 
Kirk Ward's Avatar
 
Join Date: May 2006
Location: Ellijay, GA, USA. (Talk about being in the woods!)
Posts: 1,393
Thanks: 253
Thanked 57 Times in 45 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

"We are not here to sell a parcel of boilers and vats, but the potentiality of growing rich beyond the dreams of avarice."

Dr. Samuel Johnson (Presiding at the sale of Thrales brewery, London, 1781)
Kirk Ward is offline   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 10:03 AM.