Here is my query:
$query = "SELECT last_name, first_name, DOB, site, COUNT(*) AS Num FROM student "
. "WHERE site = '{$siteRow['site']}' "
. "GROUP BY last_name, first_name, DOB having Num > 1";
When I run this on a MySQL client, I get the appropriate rows. last_name, first_name, DOB, site, and Num
However, when I try to do this (and testing with a var_dump) thru php, I get those same five col;umns, but before each one, I get 0,1,2,3, and 4 - each one corresponding with the 5 columns above in the order written.
Here is php:
$result = $DB->query($query);
$cnt = $DB->count($result);
if ($cnt > 0) {
while ($row = $DB->fetch_array($result)) { // solved; issue here!
if (!in_array(strtolower(trim($row['site'])), $dup_student_sites)) {
$records[] = $row;
$dup_student_sites[] = strtolower(trim($row['site']));
$dupCount++;
}
}
}
var_dump($records); // tested here to see result with row numbers
Here is the output of the var_dump (partial):
array(111) {
[0] =>
array(10) {
[0] =>
string(7) "---"
's_s_last_name' =>
string(7) "---"
[1] =>
string(4) "---"
's_s_first_name' =>
string(4) "---"
[2] =>
string(10) "2003-03-20"
's_s_DOB' =>
string(10) "2003-03-20"
[3] =>
string(8) "---"
's_s_site' =>
string(8) "---"
[4] =>
string(1) "2"
'Num' =>
string(1) "2"
}