Voetsjoeba
June 18th, 2003, 02:07 PM
Hi everybody, me again :)
I got the MySQL tables to work at last. What I have now is a table called news, in which there are 4 fields and two rows of data. See the image below:
Image taken out due to server downtime
So I have this script to put the data in a table.
<?php
mysql_connect("hostname","username","password");
mysql_select_db("mydatabase");
$qr = mysql_query("SELECT * FROM news");
$nrows = mysql_num_rows($qr);
for ($i=0; $i < $nrows; $i++) {
$row = mysql_fetch_array($qr);
}
?>
<html><head></head><body>
<table border="0" cellpadding="0" width="50%" cellspacing="0" height="124">
<tr>
<td width="100%" bgcolor="#FFFFCC" height="21"><? echo "<b>".$row['titel']."</b> ".$row['datum'];?></td>
</tr>
<tr>
<td width="100%" bgcolor="#FFFFFF" height="103"><? echo $row['inhoud']."<br>";?></td>
</tr>
</table>
</body>
</html>
This works fine so far, see an example of one the created table here (http://voetsjoeba.asianillusion.com/test2.php). The problem is, how can I automatically add a table (in the PHP file, not in the database) when I add a new row of data to the database ? I had one row first, and it worked fine, but when I added one, the script I have now shows the second one one instead of the first.
Can someone help me out please ?
I got the MySQL tables to work at last. What I have now is a table called news, in which there are 4 fields and two rows of data. See the image below:
Image taken out due to server downtime
So I have this script to put the data in a table.
<?php
mysql_connect("hostname","username","password");
mysql_select_db("mydatabase");
$qr = mysql_query("SELECT * FROM news");
$nrows = mysql_num_rows($qr);
for ($i=0; $i < $nrows; $i++) {
$row = mysql_fetch_array($qr);
}
?>
<html><head></head><body>
<table border="0" cellpadding="0" width="50%" cellspacing="0" height="124">
<tr>
<td width="100%" bgcolor="#FFFFCC" height="21"><? echo "<b>".$row['titel']."</b> ".$row['datum'];?></td>
</tr>
<tr>
<td width="100%" bgcolor="#FFFFFF" height="103"><? echo $row['inhoud']."<br>";?></td>
</tr>
</table>
</body>
</html>
This works fine so far, see an example of one the created table here (http://voetsjoeba.asianillusion.com/test2.php). The problem is, how can I automatically add a table (in the PHP file, not in the database) when I add a new row of data to the database ? I had one row first, and it worked fine, but when I added one, the script I have now shows the second one one instead of the first.
Can someone help me out please ?