I need to get the result rows as date wise for example, i have
prs_id date desc
1 2015-07-10 Test data1
2 2015-07-10 Test data2
3 2015-07-11 Test data3
med_id prs_id drug dosage
1 1 Pracetamol 3
2 1 calpol 4
3 2 crocin 5
4 3 xxxxxx 8
i need to form the array and need to display like the below
2015-07-10
1 Test data1
1 1 Pracetamol 3
2 1 calpol 4
2 Test data2
3 3 crocin 5
2015-07-11
3 Test data3
4 3 xxxxxx 8
I tried the following code
$sql = "SELECT * from prescriptions";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
$answer[$row['prs_created_date']][] = $row;
}
}
below code simply prints the array, with prescription data as the key, thanks Marc B for this. But i need to print as the expected table, how can i do that.
echo '<pre>';
print_r($answer);