Register on the forum now to remove ALL ads + popups + get access to tons of hidden content for members only!

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, 08: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 08:33 PM..
alanwaston is offline   Reply With Quote

Old 12-24-2016, 09: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, 12:07 AM   #3
lolipop99
Registered User
 
Join Date: Dec 2016
Posts: 96
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, 03:40 AM   #4
Nandu41
Registered User
 
Join Date: Sep 2016
Posts: 71
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
Variable names chinmay.sahoo PHP / mySQL 2 08-26-2016 11:18 PM
Variable names chinmay.sahoo HTML / DHTML 4 07-14-2016 12:20 AM
How to generate traffic for a single static webpage? Ruby707 Search Engine Optimization 9 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 10:58 AM.


Powered by vBulletin Copyright © 2013 vBulletin Solutions, Inc.