Here's a very simplified example of what I am trying to achieve :
GIFT
sender | type
phil | 1
phil | 2
Here, 1 = cake and 2 = muffin.
$table = query("SELECT sender, type FROM users WHERE sender = Phil");
foreach ($table as $row) {
$sender = $row['sender'];
$type = $row['type'];
echo '$sender has bought a $type';
}
This will output :
Phil has bought a 1
Phil has bought a 2
How can I get the below output instead ?
Phil has bought a cake
Phil has bought a muffin
Should I use an array ?
$type = array(
1 => 'cake',
2 => 'muffin'
);
The problem is $type is already defined as $row['type'].