<?php
$post = 3;

// Nawiązanie połączenia z bazą danych i zapytanie
// o wpis, jeśli podany jest jego identyfikator
mysql_connect('localhost','nazwa_uzytkownika','haslo');
mysql_select_db('baza_danych');

$rows = mysql_query("select comment_ID, comment_author, comment_content from wp_comments 
where comment_post_ID = '$post' AND comment_approved = '1' order by comment_ID");

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="pl" xml:lang="pl">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Sprawdzanie i aktualizacje</title>
<style type="text/css">
#list
{
     border: 1px solid #ccc;
     margin: 20px;
     padding: 10px;
     width: 600px;
}
.comment
{
     background-color: #ddd;
     font: 12px arial sans-serif;
     margin: 10px 0;
     padding: 5px;
     width: 400px;
}
form, #preview
{
     border: 1px solid #cc0;
     margin: 20px;
     padding: 10px;
     width: 600px;
}
</style>
<script type="text/javascript" src="addingajax.js">
</script>
<script type="text/javascript" src="fat.js">
</script>
<script type="text/javascript" src="getcomments.js">
</script>
<script type="text/javascript">
//<![CDATA[

// Zmienna globalna
<?php echo "var post = '$post';"; ?>
</script>
</head>
<body>
<div id="list">
<h3>Bieżące komentarze:</h3>
<?php

   if(($rows) && mysql_num_rows($rows) > 0) {
      $ctr = 0;
      while($row = mysql_fetch_row($rows)) {
?>
       <div class="comment" id="div<?php echo $row[0]; ?>">
       <?php echo $row[2]; ?></div>
<?php }
    }
?>
</div>
<form action="addcomment.php" id="commentform">
<div>
<label for="comment">Komentarz:</label>
<textarea id="comment" cols="65" rows="5"></textarea>
<br /><br />
<input type="submit" value="Zapisz" />
</div>
</form>
</body>
</html>
