Reputation: 7520
Just want to ask how can I create a simple query using CSCART?
I have this query in my code but it doesn't display my query result. Here's my code:
$company_list = db_query('SELECT company FROM cscart_companies ORDER BY company LIMIT 100');
fn_print_r($company_list);
foreach($company_list as $t){
echo $t['company'];
}
But it only display the value from my print_r() which is:
mysqli_result Object
(
[current_field] => 0
[field_count] => 1
[lengths] =>
[num_rows] => 100
[type] => 0
)
Upvotes: 1
Views: 2758
Reputation: 11
For me this works:
$company_list = db_get_array('SELECT company FROM ?:companies ORDER BY company LIMIT 100');
foreach ($company_list as $t){
foreach ($t as $r) {
echo $r['company'];
}
}
Upvotes: 1
Reputation: 625
You need to use
$company_list = db_get_array('SELECT company FROM ?:companies ORDER BY company LIMIT 100');
foreach($company_list as $t){
echo $t['company'];
}
Upvotes: 4