I’m sure this is a simple thing, however, I can’t seem to figure it out…
I have an array pulled from mysql
[CODE]
$DATA=array();
$query=mysql_query(“SELECT * FROM ads_national WHERE type=’$type’ ORDER BY rand() “);
$num_rows = mysql_num_rows($query);
if($num_rows > 0) {
while($ROW = mysql_fetch_array($query, MYSQL_ASSOC) ) {
$DATA[] = $ROW;
}
}
return $DATA;
$DATA now contains 4 rows of info including fields url, alt and imgName
I normally create a loop to display the data how I want such as
[CODE]
foreach($DATA as $row) {
echo $row[‘url’];
echo $row[‘alt’];
echo $row[‘imgName’];
}
The problem I have is I don’t want to display all 4 rows in the same place. I want to display the first 2 rows in one area of the page, and the last 2 rows somewhere else on the page.
It seems I should do something like this, but its not working
[CODE]
//display this row here….
echo $DATA[0][‘url’];
echo $DATA[0][‘alt];
echo $DATA[0][”imgName’];
… some other html/php
//display this row somewhere else
echo $DATA[1][‘url’];
echo $DATA[1][‘alt];
echo $DATA[1][”imgName’];
How do I take that array and display its values in various places on the page without the loop?
Thanks in advance.