<head>

<title>Strona domowa</title>

<script>
function limitText(limitField, limitNum) {
if (limitField.value.length > limitNum) {
limitField.value = limitField.value.substring(0, limitNum);
}
}
</script>

</head>

<body>

<h3> Co będziesz robić? <br>(lub co chcesz, by myśleli inni, że robisz)

</h3><br>
<form name=mainform method=post action=add.php onSubmit="return checkLength(this)">

<textarea name="message" rows="3" cols="80" onKeyDown="limitText(this,140);"
onKeyUp="limitText(this,140);">
</textarea> <br>
<input type=submit value='Dodaj przyszłą wiadomość'>

</form>
<br>

<?php
include("config.php");
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Nie można otworzyć bazy danych");
$query="SELECT * FROM lista where status=0 order by id desc";
$result=mysql_query($query);

$numOfRecords=mysql_numrows($result);

mysql_close();

echo "<b>Moje przyszłe wiadomości</center></b><br><hr>";

?>

<table border="1" cellspacing="2" cellpadding="2">
<tr>
<td><b>id</b></td>
<td><b>Wiadomość</b></td>
<td><b>Stan</b></td>
</tr>

<?
$i=0;
while ($i < $numOfRecords) {
$id=mysql_result($result,$i,"id");
$message=mysql_result($result,$i,"message");
$status=mysql_result($result,$i,"status");
?>

<tr>
<td nowrap><? echo "$id"; ?></td>
<td width=350><? echo "$message"; ?>

<?php

$tmp = "";
if ($status < 1) {
$tmp = "Nie wysłano";
}

?>
&nbsp; <a href="delete.php?id=<?php echo $id ?>">Usuń</a>
</td><td nowarp><? echo "$tmp"; ?></td>
</tr>
<?
$i=$i+1;
}
?>
</table>
</body>
</html>