views:

116

answers:

2

Here's what I got-

 $awards_sql_1 = mysql_query('SELECT * FROM categories WHERE section_id = 1') or die(mysql_error());
 $awards_rows_1 = mysql_num_rows($awards_sql_1);
 $awards_sql_2 = mysql_query('SELECT * FROM categories WHERE section_id = 2') or die(mysql_error());
 $awards_sql_3 = mysql_query('SELECT * FROM categories WHERE section_id = 3') or die(mysql_error());
 $awards_sql_4 = mysql_query('SELECT * FROM categories WHERE section_id = 4') or die(mysql_error());

 $i = 0;
 $records = mysql_num_rows($sections_query);
 while($row_sections = mysql_fetch_array($sections_query)) {
  echo "<h3>" . $row_sections['section_name'] . "</h3>";
  echo "<ul>";
  //while($categories = mysql_fetch_array($awards_sql_1)) {
  for ($i = 0; $i < $awards_rows_1; $i++) {
   echo "<li><strong>$categories['category_name']</strong>";

  }
  echo "</ul>";
 }

For some reason, if I comment out the for() nested in the while(), the page will load fine and I'll see all of my h3's, however, whenever I try to nest a for() or while() inside the original while(), the page just goes blank on reload.

What am I doing wrong?

+1  A: 

Try with, you'll get the error:

<?php
error_reporting(E_ALL);
...
inakiabt
This won't work for parse errors unfortunately
Tom Haigh
+3  A: 

You need to put braces around array variables embedded in strings, otherwise you get a parse error.

 echo "<li><strong>{$categories['category_name']}</strong>";

http://php.net/manual/en/language.types.string.php#language.types.string.parsing

Tom Haigh
thank you, that solved the blank page problem. didn't know that!
Marty