Noobster Noobster - 2 months ago 4x
PHP Question

php - how to exclude a line of code in a loop

I have a code in HTML in a table. And I want the loop to just ignore them

$sel_admin = "query ";
$rs_admin = mysql_query($sel_admin);
while($row = mysql_fetch_array($rs_admin))
echo "<th>". $row['a']. "</th>";

</thead> // This two line of code
<tbody> // is the one I want to exclude in the while loop

$sel_admin2 = "query2 ";
$rs_admin2 = mysql_query($sel_admin2);
while($row2 = mysql_fetch_array($rs_admin2))
echo" <tr class='gradeX'> ";
echo "<td>" . $row2['sched3_time']. "</td>";

Is this even possible?


I'm guessing you want those lines printed once, not to be outside the loop, per se. You could use a variable to track it:

$linesNeeded = true;
while (...) {
  if ($linesNeeded) {
    echo $line1;
    echo $line2;
    $linesNeeded = false;