Parašė AudriusGisas· 2017 Rugp. 10 16:08:29
#2
Kad nekurt naujos temos, prie to paties gal kas zinote kaip sitame scripte padaryt kad rodytu, tik paskutinius 5 atsiliepimus.
<?php
mysql_connect('', '', '') or die("MySQL Error!<br>(".mysql_error().")<br>Could not proceed");
mysql_select_db('');
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>";
}
?>
Redagavo AudriusGisas· 2017 Rugp. 10 17:08:50