Hi,
I'm trying to optimize my Php code and the connection to the database, by making two different parts into the php file :
The first deals whit the mysql connection, registering all vars into arrays and double arrays.
The second print all the text, by looping the vars into a for() function.
But the only thing I get, intead of having the contents of the vars printed on the output page, is something like this :
"Array[1] Array[2] Array[3]...".
I'm sure something is wrong concerning the double array, but I can't see what...
Here is the code :
include("includes/connect.php");
$query1="SELECT * FROM categories1 ORDER BY categ";
$result1=mysql_db_query($db, $query1);
while ($tbl1=mysql_fetch_array($result1)){
$i1++;
$id1[$i1]=$tbl1["id"];
$categories1[$i1]=$tbl1["categ"];
$query2="SELECT * FROM categories2 WHERE lvlup='$id1[$i1]' ORDER BY nbsites DESC LIMIT 3";
$result2=mysql_db_query($db, $query2);
while ($tbl2=mysql_fetch_array($result2)){
$i2++;
$id2[$i1][$i2]=$tbl2["id"];
$categories2[$i1][$i2]=$tbl2["categ"];
}
}
mysql_close();
$ii1=$i1;
for ($i1=1; $i1<=$ii1; $i1++){
echo "<br><a href=\"?page=categories2&id1=$id1[$i1]\" class=\"txtvert\"><b>$categories1[$i1]</b></a><br>";
for ($i2=1; $i2<=3; $i2++){
echo "<a href=\"?page=categories3&id1=$id1[$i1]&id2=$id2[$i1][$i2]\" class=\"txtvert\">$categories2[$i1][$i2]</a> ";
}
}
Thank you very much for your help !