So this question is probably pretty basic.
I am wanting to create an array from selected elements from a SQL table.
I am currently using:
$rcount = mysql_num_rows($result);
for ($j = 0; $j <= $rcount; $j++)
{
$row = mysql_fetch_row($result);
$patients = array($row[0] => $row[2]);
}
I would like this to return an array like this:
$patients = (bob=>1, sam=>2, john=>3, etc...)
Unfortunately, in its current form, this code is either copying nothing to the array or only copying the last element.
Try this instead.
If it doesn’t work, there’s something wrong with your query.