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
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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.