MySQL help
Posted
#4640
(In Topic #938)
Returning all rows from table
I'm creating a new symbol to pull all rows from a specific table, but I've hit a roadblock: it seems my returned results are in an array, but I have no idea how to convert that to a string. I tried using PHP's implode() but this just caused errors about array to string conversions.Code (php)
$db = $GLOBALS['SITE_DB'];
$sql = 'SELECT ' . $param[0] . ' FROM ' . $db->get_table_prefix() . 'catalogue_categories WHERE c_name="' . $param[1] . '"';
$query = $db->query($sql);
return json_encode($query);
$sql = 'SELECT ' . $param[0] . ' FROM ' . $db->get_table_prefix() . 'catalogue_categories WHERE c_name="' . $param[1] . '"';
$query = $db->query($sql);
return json_encode($query);
Returns this:
[{"cc_title":"Contact Us"},{"cc_title":"Overview"},{"cc_title":"Features, Tools, & Modules"},{"cc_title":"Help & Support home"},{"cc_title":"Overview"},{"cc_title":"General"},{"cc_title":"Website"},{"cc_title":"Member Sites"},{"cc_title":"Opportunities"},{"cc_title":"Training"},{"cc_title":"Forums"},{"cc_title":"Profile & Accounts"},{"cc_title":"PRO Membership"}]
How do I get rid of all the junk here and just return all cc_title's (maybe seperated by commas)?
Posted
Code
return implode(',', collapse_1d_complexity('cc_title', $query));
0 guests and 0 members have recently viewed this.
