Código PHP:
require "conf.inc.php";
$numComments = 2;
$NumLow = 0;
$sql = 'SELECT * FROM `' . $table . '`';
$allComments = mysql_query($sql, $DBConn) or die("Error in GuestBook Application: " . mysql_error());
$numallComments = mysql_num_rows($allComments);
// Fetch page-wise comments from database table
$sql .= ' ORDER BY `time` DESC LIMIT ' . $NumLow . ', ' . $numComments;
$fewComments = mysql_query($sql, $DBConn) or die("error 123: " . mysql_error());
$numfewComments = mysql_num_rows($fewComments);
while ($array = mysql_fetch_array($fewComments)) {
$titulo_noticia = mysql_result($fewComments, $i, 'titulo_noticia');
$fuente = mysql_result($fewComments, $i, 'fuente');
$noticia = mysql_result($fewComments, $i, 'noticia');
$time = mysql_result($fewComments, $i, 'time');
echo '<div class="sidebar"><h3><p align="center"> Noticias GBelectronics </p></h3><h3>'$titulo_noticia'</h3><h5>'$time'</h5><p>'$noticia'</p><ul><li>'$fuente'</li></ul></div>';
$i++;
}
Código HTML:
<div id="sidebar_container"> <?php include("noticias/GuestBook.php"); ?> </div>