PHP beginner |
|
Om dit te doen:
[naam] [naam]
[content] [content]
[links] [links]
<table>
<?php
$query = mysql_query("SELECT naam, content, links FROM merchant") or die (mysql_error());
while($row = mysql_fetch_array()) {
?>
<tr><td>Naam</td>
<td><?php echo $res['naam']; ?></td>
</tr>
<tr><td>Content</td>
<td><?php echo $row['content']; ?></td>
</tr>
<tr><td>Links</td>
<td><?php echo $row['links']; ?></td>
</tr>
</html>
<?php
} // Einde While-lus
?>
</table>
<table> <?php ?> <tr><td>Naam</td> <td> <?php echo $res['naam']; ?></td> </tr> <tr><td>Content</td> <td> <?php echo $row['content']; ?></td> </tr> <tr><td>Links</td> <td> <?php echo $row['links']; ?></td> </tr> </html> <?php } // Einde While-lus ?> </table>
EDIT: Nu ga je zo'n resultaat verkrijgen:
[naam] [naam]
[content] [content]
[links] [links]
[naam] [naam]
[content] [content]
[links] [links]
...
Indien je ev. zou willen dat de linkerhelft van de tabel niet steeds herhaal wordt, doe je zoiets:
<table>
<tr>
<td>Naam</td>
<td>Content</td>
<td>Links</td>
</tr>
<?php
// Query + while uitvoeren
?>
<tr>
<td><?php echo $row['naam']; ?></td>
<td><?php echo $row['content']; ?></td>
<td><?php echo $row['links']; ?></td>
</tr>
</table>
<table> <tr> <td>Naam</td> <td>Content</td> <td>Links</td> </tr> <?php // Query + while uitvoeren ?> <tr> <td> <?php echo $row['naam']; ?></td> <td> <?php echo $row['content']; ?></td> <td> <?php echo $row['links']; ?></td> </tr> </table>
|