as the title said, i've this block of code and i want to know if i can write a variable that takes the name of another one similar to it but outside the loop.
is that makes a problem ?!
<?php
$query = "SELECT * FROM subjects";
$subjects_set = mysql_query($query);
errors_of($subjects_set);
while ($db_subjects_rows = mysql_fetch_array($subjects_set)){
echo "<li>{$db_subjects_rows["menu_name"]}</li>";
$pages_set = mysql_query("SELECT * FROM pages WHERE subject_id = {$db_subjects_rows["id"]}");
errors_of($pages_set);
echo "<ul class=\"pages\">";
while ($db_pages_rows = mysql_fetch_array($pages_set)){
echo "<li>{$db_pages_rows["menu_name"]}</li>";
}
echo "</ul>";
}
?>
mysql_*functions in new code. They are no longer maintained and are officially deprecated. See the red box? Learn about prepared statements instead, and use PDO or MySQLi - this article will help you decide which. If you choose PDO, here is a good tutorial.