Site Owners Forums - Webmaster Forums

Site Owners Forums - Webmaster Forums (http://siteownersforums.com/index.php)
-   PHP / mySQL (http://siteownersforums.com/forumdisplay.php?f=10)
-   -   How to put the array into a single variable (http://siteownersforums.com/showthread.php?t=181997)

alanwaston 12-22-2016 09:13 PM

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 "
"; 
print "Total DOM 0 = ";
print_r($results);
print "
";

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

riyadh 12-24-2016 10:56 AM

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'];

lolipop99 12-25-2016 01:07 AM

we dont know code from university

Nandu41 01-02-2017 04:40 AM

Nice..Thank you for sharing this information!!


All times are GMT -7. The time now is 04:36 AM.


Powered by vBulletin Copyright © 2020 vBulletin Solutions, Inc.