Jump to content

kruistabel


reijm1

Recommended Posts

Hallo allemaal,

Ik heb via een xml data uit een kruistabel gehaald, en deze netjes in een tabel geplaatst. Tot zover gaat het allemaal goed. Maar ik wil graag de niet gebruikte cellen in de kruistabel zwart vullen, zodat je direct ziet dat deze niet gebruikt wordt:

Een voorbeeld van de xml is:

 

<root>
<row>
<Klasse>A1F</Klasse>
<rij_0/>
<rij_1>Fortuna A2</rij_1>
<rij_2>IJsselvogels A1</rij_2>
<rij_3>KCR A2</rij_3>
<rij_4>KOAG A1</rij_4>
<rij_5>KVS A2</rij_5>
<rij_6>ODO A1</rij_6>
<rij_7>Vitesse A1</rij_7>
<rij_8>Weidevogels A1</rij_8>
</row>
<row>
<Klasse>A1F</Klasse>
<rij_0>Fortuna / MHIR A2</rij_0>
<rij_1/>
<rij_2>8 - 20</rij_2>
<rij_3>6 - 8</rij_3>
<rij_4>5 - 17</rij_4>
<rij_5/>
<rij_6>10 - 17</rij_6>
<rij_7>9 - 9</rij_7>
<rij_8>14 - 16</rij_8>
</row>
<row>
<Klasse>A1F</Klasse>
<rij_0>IJsselvogels A1</rij_0>
<rij_1/>
<rij_2/>
<rij_3>14 - 14</rij_3>
<rij_4>5 - 8</rij_4>
<rij_5>11 - 8</rij_5>
<rij_6/>
<rij_7>9 - 6</rij_7>
<rij_8>13 - 13</rij_8>
</row>
<row>
<Klasse>A1F</Klasse>
<rij_0>KCR A2</rij_0>
<rij_1>16 - 11</rij_1>
<rij_2>7 - 17</rij_2>
<rij_3/>
<rij_4>7 - 13</rij_4>
<rij_5>13 - 5</rij_5>
<rij_6>7 - 12</rij_6>
<rij_7/>
<rij_8>11 - 10</rij_8>
</row>
<row>
<Klasse>A1F</Klasse>
<rij_0>KOAG A1</rij_0>
<rij_1/>
<rij_2>7 - 6</rij_2>
<rij_3>13 - 7</rij_3>
<rij_4/>
<rij_5>17 - 3</rij_5>
<rij_6>18 - 8</rij_6>
<rij_7>14 - 7</rij_7>
<rij_8>15 - 6</rij_8>
</row>
<row>
<Klasse>A1F</Klasse>
<rij_0>KVS A2</rij_0>
<rij_1>10 - 9</rij_1>
<rij_2>7 - 17</rij_2>
<rij_3>11 - 7</rij_3>
<rij_4>4 - 16</rij_4>
<rij_5/>
<rij_6>6 - 18</rij_6>
<rij_7>8 - 17</rij_7>
<rij_8/>
</row>
<row>
<Klasse>A1F</Klasse>
<rij_0>ODO A1</rij_0>
<rij_1>10 - 5</rij_1>
<rij_2>10 - 4</rij_2>
<rij_3/>
<rij_4>9 - 10</rij_4>
<rij_5>19 - 11</rij_5>
<rij_6/>
<rij_7/>
<rij_8>13 - 7</rij_8>
</row>
<row>
<Klasse>A1F</Klasse>
<rij_0>Vitesse A1</rij_0>
<rij_1>17 - 6</rij_1>
<rij_2/>
<rij_3>14 - 5</rij_3>
<rij_4>9 - 11</rij_4>
<rij_5>16 - 10</rij_5>
<rij_6>8 - 9</rij_6>
<rij_7/>
<rij_8>9 - 7</rij_8>
</row>
<row>
<Klasse>A1F</Klasse>
<rij_0>Weidevogels A1</rij_0>
<rij_1>14 - 9</rij_1>
<rij_2>12 - 15</rij_2>
<rij_3>12 - 8</rij_3>
<rij_4/>
<rij_5>7 - 7</rij_5>
<rij_6>13 - 14</rij_6>
<rij_7>9 - 11</rij_7>
<rij_8/>
</row>
</root>

 

Zijn er mensen die er ervaring mee hebben?

Vraag 2:
Ik heb nu handmatig de rijen 0 - 8 als rij ingevoerd, is het mogelijk om de rijen automatisch op basis van de xml te vullen, en daarnaast ook de velden in de <th> velden om die automatisch te vullen?

 

 

Kruistabel
<table cellpadding="1px" width="100%">
<tr align="left">
<th><?php echo $kruistabel -> rij_0 ?></th><th><?php echo $kruistabel -> rij_1 ?></th><th><?php echo $kruistabel -> rij_2 ?></th><th><?php echo $kruistabel -> rij_3 ?></th><th><?php echo $kruistabel -> rij_4 ?></th><th><?php echo $kruistabel -> rij_5 ?></th>
</tr>

<?
foreach ( $xmlkruis->row AS $kruistabel )
{
?>

<tr class="<?php echo ($clrCounter++ % 2 == 0 ? 'odd' : 'even'); ?>">
    <td><?php echo $kruistabel -> rij_0 ?></td>
    <td><?php echo $kruistabel -> rij_1 ?></td>
    <td><?php echo $kruistabel -> rij_2 ?></td>
    <td><?php echo $kruistabel -> rij_3 ?></td>
    <td><?php echo $kruistabel -> rij_4 ?></td>
    <td><?php echo $kruistabel -> rij_5 ?></td>
    <td><?php echo $kruistabel -> rij_6 ?></td>
    <td><?php echo $kruistabel -> rij_7 ?></td>
    <td><?php echo $kruistabel -> rij_8 ?></td>
</tr>

<?}?>
</table>
Link to comment
https://forums.phpfreaks.com/topic/278201-kruistabel/
Share on other sites

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.