i use this function to call my database
function get_prescriptionWith_4($ID){
$sql = "SELECT prescriptions FROM tblprescriptions WHERE `ID`='$ID'";
$query = $this->dbh->prepare($sql);
$query->execute();
$row = $query->fetchAll(PDO::FETCH_ASSOC));
return @$row;
}
my database table looks like this..
ID | prescription
1 | Med (gen) 20 -- #20/1X per day --morning--for 30 days/,
1 | test (test) 23 -- #343/1X per day --morning and noon-- 120 days23/,
samp (rere) 44 -- #34/1X per day --morning-- 7 days44/,
1 | asd (asd) 22 -- #222/3X per day --morning noon and evening--30 days/,
qw (wq) 44 -- #222/3X per day --morning noon and evening--60 days/,
1233 (123) 21 -- #123213/1X per day --morning--- 60 days/,
what i wanted to achieve is to load all prescription with the same id and since row prescription have multiple data inside it i use explode
to separate the data with , when i tried to use Fetch(PDO::FETCH_ASSOC)
i only returns the first prescription i think that using fetchAll might be better to fetch all data from my database..
$pres_array3=$patient->get_prescriptionWith_4($ID);
$new_array3=explode(',',$pres_array3,-1);
but when i use echo $new_array3
to check nothing is being return if it is on fetchAll