Skip to content Skip to sidebar Skip to footer

How Do I Not Display Certain Parts Of The Table From My Database?

http://i.stack.imgur.com/5OTgG.png The image above describes my problem, and provides a visual. As you can see, I just want to reserve or delete the two spaces on the top-right. Ho

Solution 1:

In your loop, you'd need to put in some conditional statement to break from the default behavior.

while($objResult = mysql_fetch_array($objQuery))
{
    if(($intRows)%4==0)
    {
        echo"<tr>"; // You forgot this.
    }

    echo "<td>";
    $intRows++;
    if ($intRows == 3 || $intRows == 4) : 
?>
    <!-- special cells --><?else:
?><center><imgsrc="https://s3.amazonaws.com/thumbnails/<?=$objResult["Picture"];?>"height="190"width="190" /></a><br><?=$objResult["albumName"];?><br></center><?phpendif;

    echo"</td>";
    if(($intRows)%4==0)
    {
        echo"</tr>";
    }
}
// You also need this part:echo ($intRows %4 > 0 ? "</tr>" : "") . "</table>";

Solution 2:

Your $intRows variable seems to be counting cells, not rows. So you can simply identify the top right cells by their numbers, which should be 2 and 3. Add this to your loop:

$cell = 0;
echo'<table border="1" cellpadding="2" cellspacing="1"><tr>';
while($objResult = mysql_fetch_array($objQuery))
{
  if($cell % 4 == 0) {
    echo'</tr><tr>';
  }

  if($cell == 2 || $cell == 3) {
    echo'<td>RESERVED</td>';
  } else {
    echo'<td>'.$objResult["albumName"].'</td>';
  }

  $cell++;
}
echo'</tr></table>';

Post a Comment for "How Do I Not Display Certain Parts Of The Table From My Database?"