Go Back   Site Owners Forums - Webmaster Forums > Web Programming > Programming General > PHP / mySQL

Notices


Reply
 
Thread Tools Rate Thread Display Modes
Old 12-22-2016, 09:13 PM   #1
alanwaston
Registered User
 
Join Date: Dec 2016
Posts: 5
How to put the array into a single variable

Mysql looks like the below.. how can I capture the single result into a single variable..
I tried $results[total] and $results[0] but neither worked for me..
I want it to look like $mycount = 88 or something similar.

$results = $wpdb->get_results('SELECT COUNT(*) FROM wp_realty_listingsdb WHERE DOM = 0');
print "<pre>";
print "Total DOM 0 = ";
print_r($results);
print "</pre>";

(
[0] => stdClass Object
(
[COUNT(*)] => 88
)
)
__________________________________________________ ____
Relax: instrumental ringtones, country music ringtones, message tones

Last edited by alanwaston; 01-08-2017 at 09:33 PM..
alanwaston is offline   Reply With Quote

Old 12-24-2016, 10:56 AM   #2
riyadh
Registered User
 
Join Date: Dec 2016
Posts: 11
Change the query like this :

$results = $wpdb->get_results('SELECT COUNT(*) as mycount FROM wp_realty_listingsdb WHERE DOM = 0');

Capture result :

$mycount = $results[0]['mycount'];
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Webmaster of
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
riyadh is offline   Reply With Quote
Old 12-25-2016, 01:07 AM   #3
lolipop99
Registered User
 
Join Date: Dec 2016
Posts: 87
we dont know code from university
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
lolipop99 is offline   Reply With Quote
Old 01-02-2017, 04:40 AM   #4
Nandu41
Registered User
 
Join Date: Sep 2016
Posts: 65
Nice..Thank you for sharing this information!!
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Nandu41 is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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 Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to generate traffic for a single static webpage? Ruby707 Search Engine Optimization 7 09-02-2015 02:30 AM
ASP Array Question mjvndhsb ASP 1 05-15-2014 03:27 AM
Not allowing duplicate values to an array mjvndhsb Javascript 3 03-11-2014 12:40 AM


All times are GMT -7. The time now is 02:33 PM.


Powered by vBulletin Copyright © 2020 vBulletin Solutions, Inc.