Hello, maybe anyone can help me? How to in this script set max 5 testimonials per page, only lasts testiomonials??
PHP Code:<?php
mysql_connect('localhost', 'gultaisa_db', 'IJ0qAEZ8') or die("MySQL Error!<br>(".mysql_error().")<br>Could not proceed");
mysql_select_db('gultaisa_db');
$rowsPerPage = 1; //number of results you want to display
if(isset($_POST['submit'])){
if(empty($_POST['name']) || empty($_POST['comment'])) {
die("Forget to fill something in?");
}
$_POST['comment'] = addslashes($_POST['comment']);
mysql_query("INSERT INTO `testimonials`
(`name`,`text`,`norp`,`date`) VALUES ('".$_POST['name']."', '".$_POST['comment']."', '".$_POST['norp']."', '".time()."')")or die("MySQL Error!<br>(".mysql_error().")<br>Could not proceed");
header("Location: ".$_SERVER['PHP_SELF']);
}
$query = mysql_query("SELECT * FROM `testimonials` ORDER BY `id`");
$i = 0;
echo "<h3>Atsiliepimai</h3><div style='width: 500px'>";
while($row = mysql_fetch_assoc($query)){
$i = ($i == 2) ? 0 : 1;
$bg = ($i == 1) ? "background-color: lightgrey;" : "background-color: #FFF;";
echo "
<p style='".$bg." margin: 0; padding: 5px 0 0 0; height: 100px; font-family: arial; border-bottom: 1px solid black'>
<b>".$row['name']." </b><br /><br />
".$row['text']."
</p>";
}
?>


Reply With Quote

Bookmarks