Location: PHPKode > scripts > Comments script with pagination > comm/new.php
<?php
$new_reset = 'resetcheck.txt';  // Fisierul ce contine timpul ultimei resetari
include('config.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="ro">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title><?php echo $clsite['comments']['newcomm']; ?></title>
<link href="../commincls/style_c.css" rel="stylesheet" type="text/css" />
<style type="text/css">
.rosu {
  color:red;
}
#fnew {
  background-color:#f8f8fc;
  font-family:Calibri, sans-serif;
  font-size:16px;
  padding:3px;
}
</style>
</head>
<body>
<center>
<?php
// Reset the time of last check, if data from form
 if(isset($_POST['pass_new']) && isset($_POST['timp_reset'])) {
  if ($_POST['pass_new'] == CMAPASS) {
    if ((int)$_POST['timp_reset']>11111111) {
      // write data in $new_reset
      if (!file_put_contents($new_reset, intval($_POST['timp_reset']))) {
        print('<h3 class="rosu">'.$clsite['comments']['eror_resetcheck'].'</h3>');
      }
    }
    else print '<h4 class="rosu"><u>'.$clsite['comments']['noreset'].'</u></h4>';
  }
  else print '<h4 class="rosu"><u>'.$clsite['eror_pass'].'</u></h4>';
}

// gets the time of last reset, stored in new_reset.txt
$sec = intval(file_get_contents($new_reset));
$data_reset = date('j-F-Y, G:i ', $sec);
?>

<h2 id="coments_t"><?php echo $clsite['comments']['newcomm']; ?></h2>
<div id="coments">
<?php
echo '<p class="rosu"><u>'.$clsite['comments']['lastreset'].'</u> : &nbsp; <b>'.$data_reset.'</b><br />
- <font color="blue">'.$clsite['comments']['newcommad'].'</font></p>';

$nr = 0;  // Number of comments

// create an object of BaseCM class to perform SELECT query
$obj = new BaseCM($cmysql);
// Select new added comments
$sql = "SELECT * FROM `comments` WHERE `dt`>$sec ORDER BY `id` ASC";
if($result = $obj->sqlExecute($sql)) {
  if($obj->affected_rows > 0) {
    for($i=0; $i<$obj->affected_rows; $i++) {
      $lastdt = $result[$i]['dt'];
      $result[$i]['coment'] = BaseCM::formatBbcode($result[$i]['coment']);
      $result[$i]['coment'] = str_replace('src="', 'src="../', $result[$i]['coment']);  // Coreleaza src-ul cu pozitia in care se afla 'new.php'
      $result[$i]['dt'] = date('j-F-Y, &\n\b\sp; G:i ', $result[$i]['dt']);
      $ad_link = '<span><a href="'.urldecode($result[$i]['page']).'#cm" target="_blank">Link page</a></span>';
      // Add user's website to name, if exists
      if (strlen($result[$i]['site'])>15) {
        $result[$i]['name'] = '<a href="'.$result[$i]['site'].'" id="n'.($i+1).'">'.$result[$i]['name'].'</a>';
      }
      // display comments
      echo "\r\n".'<div class="coms'.($i%2).'"><div class="n_coms">'.($i+1).'. &nbsp; '.$result[$i]['name'].' </div> <div class="nr_coms"> '.$ad_link.' </div><span class="e_coms">'. $result[$i]['email']. '</span><em class="d_coms">'. $result[$i]['dt']. '</em> &nbsp; &nbsp; &nbsp; ';
      echo '<br /><div class="c_coms">'. $result[$i]['coment']. '</div></div><hr class="linie_coms"/>'."\r\n";
    }
  }
}
?>
</div><br />
<form action="" method="post" id="fnew">
  <h4><u><?php echo $clsite['comments']['resetdt']; ?></u></h4>
  <input type="hidden" name="timp_reset" value="<?php echo $lastdt; ?>" />
  <b><i>Admin <?php echo $clsite['pass']; ?></i></b> <input type="password" name="pass_new" size="15" maxlength="40" /> &nbsp; 
  <input type="submit" value="Reset" />
</form><br />
</center>

</body>
</html>
Return current item: Comments script with pagination