Jump to content

Populating a table issues


drakal30

Recommended Posts

I have a tricky problem that I can't seem to get my head around, Here is the code:

 


$totCols = $totBanks / 58;

<table class="toFloorMap" cellspacing="1">

<tr>

   <?php
   while($count <= $totCols) {

      ?>
      <td class="toFloorMapHead" style="width: 5%;">
         Bank
      </td>
      <td class="toFloorMapHead" style="width: 5%;">
         Vendor
      </td>
      <td class="toFloorMapHead" style="width: 23%;">
         Location
      </td>
      <?php

      $count++;

}
?>
</tr>

<?php
$count = 1;

while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {

   if($count == 1) { ?> <tr> <?php }

      ?>
      <td class="toFloorMapData2">
         <?php echo $line["bank"]; ?>
      </td>

      <td class="toFloorMapData2">
         <?php echo formatVen($line["vendor"],1); ?>
      </td>

      <td class="toFloorMapData" style="text-align: left;">
         <?php echo "(" . chgZone($line["zone"],1) . ") " . $line["genDesc"]; ?>
      </td>
      <?php

      if($count == 3) {
         ?> </tr> <?php 
          $count = 1;
      }else {
         $count++;
      }

}
?>

</table>

 

The above code words great creates a table with 3 sets of headers that read Bank, Vendor, Location.  What it does not do is list the banks vertically like

1 6

2 7

3 8

4 9

5 10

Instead it is listing them horizontally

1 2 3 4

5 6 7 8

I would like it to list them horizontally, I can't seem to figure how I would about this without screwing up my format.  Any ideas to point me in a direction to go about achieving this?  Thanks.

Link to comment
https://forums.phpfreaks.com/topic/81105-populating-a-table-issues/
Share on other sites

is this what you are trying to do?

 

<table class="toFloorMap" cellspacing="1">

<tr>

   <?php

$totCols = $totBanks / 58;

   while($count <= $totCols) {

      echo '<td class="toFloorMapHead" style="width: 5%;">
         Bank
      </td>
      <td class="toFloorMapHead" style="width: 5%;">
         Vendor
      </td>
      <td class="toFloorMapHead" style="width: 23%;">
         Location
      </td>';

}
?>
</tr>

<?php
$count="1";

while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {

   if($count == 1) {

      echo '<td class="toFloorMapData2">
         '. $line["bank"] .'
      </td>

      <td class="toFloorMapData2">
         '. $line["vendor"] .'
      </td>

      <td class="toFloorMapData" style="text-align: left;">';
         echo "(" . chgZone($line["zone"],1) . ") ". $line["genDesc"] ."";
      echo '</td></tr>';
}

      else if ($count == 3) {
          $count= "1";
      }
      else {
          $count++;
      }

}

?>

</table>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.