Page is a not externally linkable
rocknbil - 4:19 pm on Apr 9, 2012 (gmt 0)
tomking, I don't understand why you're doing the complicated array thing. Do you have a reason for that? Why can't you just do this?
$query = "SELECT id, title, carImg FROM content";
$result = mySql_db_query ($dbname, $query, $link);
while($row = mysql_fetch_array($result)) {
echo "<p>id: " . $row['id'] .
"title: " . $row['title'] .
"image: " . $row['carImg'] . "</p>";
}
Put that in a test file and give it a try. It should give you exactly the same results as you have there without all the added memory used by arrays you don't really need.
If you want to "store it for later" (though there is almost always a way to avoid that,)just index it by the record ID instead of a counter.
$query = "SELECT 'id', 'title', 'carImg' FROM content";
$result = mySql_db_query ($dbname, $query, $link);
while($row = mysql_fetch_array($result)) {
echo "<p>id: " . $row['id'] .
"title: " . $row['title'] .
"image: " . $row['carImg'] . "</p>";
$hugeResultsArray[$row['id']] = array($row['title'],$row['carImg']);
}
Dereferencing it will be the same as what you're doing there, you would just use a foreach instead of a counter.