Hi there,
It has been a while since I have looked at loops/arrays but this has me stumped. I am using the following code in a couple of other locations and all is fine BUT this time I know there will only be one result from the SQL query this seems to be the issue. When I return multiple results to the while loop it works fine.
Even though there is only one result I still need the array populated in the same format/layout.
Any help?
Thanks
It has been a while since I have looked at loops/arrays but this has me stumped. I am using the following code in a couple of other locations and all is fine BUT this time I know there will only be one result from the SQL query this seems to be the issue. When I return multiple results to the while loop it works fine.
Code:
$result = $database->query("SELECT * FROM ".TBL_MAIL_SENT." WHERE UserFrom = '$session->username' AND mail_id = '$msgid'");
$mail = mysql_fetch_array($result);
$user = $mail['UserFrom'];
$mail_ary = array();
while($data = mysql_fetch_object($result)){
$mail_ary[] = array('UserFrom' => $data->UserFrom, 'UserTo' => $data->UserTo , 'Subject' => $data->Subject, 'Message' => $data->Message, 'mail_id' => $data->mail_id, 'SentDate' => $data->SentDate);
Even though there is only one result I still need the array populated in the same format/layout.
Any help?
Thanks