How to insert an array inside an array?
Posted: Wed Jun 23, 2004 11:49 am
I guess this is called a multidimensional array? I got it to work but it slowed my page down adding the $hlinksrow array. I assume because it is having to run 40 mysql queries. I am trying to have it just run 1 query and pull 40 entries from the database but I can't get it to work. How do you put an array inside an array? By the way, this code is making links for my page and randomizing the anchor text.
Code: Select all
<?php
$id = $row["id"];
$stateabb = $row["stateabb"];
$links = mysql_query("SELECT * FROM table1 WHERE id > '$id' AND stateabb = '$stateabb' LIMIT 40");
if ($linksrow = mysql_fetch_array($links)) {
do {
$hlinks = mysql_query("SELECT hlink FROM table2 ORDER BY RAND() LIMIT 1");
?>
<a style="text-decoration: none" href="/dir/subdir/<?php
echo $linksrow["url"];
?>">
<?php
echo $linksrow["city"]," ";
$hlinksrow = mysql_fetch_array($hlinks);
echo $hlinksrow["hlink"]," - ";
} while ($linksrow = mysql_fetch_array($links));
} else {
echo "None Available";
}
?>