Hi there!
I'm relatively new to php5 and mysqli (altho I have been using php4 for a while, still pretty much a n00b tho! LOL!)
Now I have written this 'ere bit of code:
if ($stmt = $mysqli->prepare("SELECT item, name, template FROM ".TABLE_MENU." ORDER BY Name")) {
$stmt->execute();
/* bind variables to prepared statement */
$stmt->bind_result($item, $name, $template);
/* fetch values */
while ($stmt->fetch()) {
$tmp = array("item" => $item,
"name" => $name,
"template" => $template);
$menu[$item] = $tmp;
}
$stmt->close();
}
$mysqli->close();
return $menu;
Which returns this array:
Array (4)
aboutus => Array (3)
item => aboutus
name => About Us
template => about
gigs => Array (3)
item => gigs
name => Gigs
template => gigs
home => Array (3)
item => home
name => Home
template => home
media => Array (3)
item => media
name => Media
template => media
The thing is... I have this nagging feeling that I have done it in a rather cack handed way, altho the output is exactly what i want!
Would anyone care to give me any insights or words of advice?
Many thanks,
d.