I can't figure out why this is so difficult. I have a SQL query that results in a column of numeric results, i.e.:
23
45
67
54
34
78
56
Using a PHP/MySQL query, I want to simply generate a comma separated list of these values that can be displayed or used elsewhere. This is the code I am using
<?php
global $wpdb;
$sql = <<<SQL
SELECT FK_T_L_INCENTIVES_ID FROM lighting_incentives.WAYPOINT_USER_PICKED WHERE WP_RECOMMENDED = 1 AND FK_USER_ID = 31
SQL;
if (!$sql) { // add this check.
die('Invalid query: ' . mysql_error());
}
$resultset = array();
$rebates = $wpdb->get_results( $sql, ARRAY_A );
foreach($rebates as $data) {
$resultset[] = $data;
}
$comma_separated = implode(",", $resultset);
print $comma_separated;
?>
For some reason I keep getting the error
mysql_fetch_array() expects parameter 1 to be resource
Any help would be much appreciated!