puting mysql results to array

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
mansour
User
Posts: 321

puting mysql results to array

Post by mansour »

Hi,
I need to put mysql results inside an array. how i can do that?

i want to save mobile numbers as an array. (eg. $recipientNumber = array( "number 1", "number 2", ..., "number n");

my code:
//get customers mobile number
$sSqlWrk = "Select BirthDate, mobile FROM patients WHERE DATE_FORMAT(BirthDate,'%m-%d') = '".CurrentBdate()."'";
$theres =$conn->Execute($sSqlWrk);
while (!$theres->EOF) {
$recipientNumber .= $theres->fields('mobile');
$theres->MoveNext();
}
$theres->Close();

above codes return: $recipientNumber = "number 1number 2number 3";

what's wrong?
Thank You
Mansour


mobhar
User
Posts: 11905

Post by mobhar »

Try this:

$sSqlWrk = "Select BirthDate, mobile FROM patients WHERE DATE_FORMAT(BirthDate,'%m-%d') = '".CurrentBdate()."'";
$theres =$conn->Execute($sSqlWrk);
$recipientNumber = "";
while (!$theres->EOF) {
$recipientNumber .= $theres->fields('mobile').","; // insert comma separator
$theres->MoveNext();
}
$theres->Close();
$recipientNumber = trim($recipientNumber, ","); // remove the last comma


mansour
User
Posts: 321

Post by mansour »

thank you for your post!
Mansour


Post Reply