I am having trouble trying to figure out how to populate a multi-dimensional array. Let's say I have a table of transactions with various billing dates. First I have an array that retrieves the following 'billed' dates:
Array
(
[0] => Array
(
[BILLED] => 2011-11-18 00:00:00
)
[1] => Array
(
[BILLED] => 2011-11-22 00:00:00
)
)
I also have the following query which is currently hard-coded to one of the two 'billed' dates shown above:
$qryOrders = $this->db->query("
SELECT tblOrders.*
FROM tblOrders
WHERE tbltc.BILLED = '2011-11-22'");
$data['Orders'] = $qryOrders->result_array();
I know that I can very easily determine the count of array items by using count($Orders); but how can I instead pass through each of the 'billed' dates of 2011-11-18 and 2011-11-22 to that I can determine the overall count, for both of the specified dates?
I hope I've explained it clearly enough. I am thinking that I probably need some kind of foreach loop and each time through the loop I could pass in the billed date, and keep track of a running total each time through the loop.
Any ideas would be greatly appreciated. Thanks,
// this is getting all results for a record
$sql =
<<<sql
SELECT tblOrders.*
FROM tblOrders
WHERE tbltc.BILLED between '{$arr[0]}' and '{$arr[1]}'
sql;
// this is to get total count of matched record
// $sql = 'select count(*) from ..';
if you are using CI, you can easily using bind
example:-
$sql = 'SELECT tblOrders.* FROM tblOrders WHERE tbltc.BILLED between ? AND ?';
$this->db->query($sql, array($arr[0], $arr[1]));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.