Paginare si afisarea postariilor pe 2 coloane
Scris: Dum Aug 18, 2013
Buna, am gasit si editat un script de paginare, am adaugat putin CSS pentru a le alinia pe orizontala, dar imi apar mai multe rezultate decat trebuie, am nevoie de afisarea lor 2 cate 2 una sub alta, am publicat mai jos scriptul cu modificari
Am incearcat si cu table dar tot asa imi afiseaza.
Multumesc de ajutor!
Cod: Selectaţi tot
<html>
<head>
<title>Paginare</title>
</head>
<body>
<style>
#whatever div {
display: inline;
margin: 0 1em 0 1em;
width: 30%;
}
</style>
<?php
$dbhost = 'localhost';
$dbuser = 'userbazadate';
$dbpass = 'parolabazadedate';
$rec_limit = 10;
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn )
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db('desehix_ro_fisiere');
/* Get total number of records */
$sql = "SELECT count(id) FROM utilizatori ";
$retval = mysql_query( $sql, $conn );
if(! $retval )
{
die('Could not get data: ' . mysql_error());
}
$row = mysql_fetch_array($retval, MYSQL_NUM );
$rec_count = $row[0];
if( isset($_GET{'page'} ) )
{
$page = $_GET{'page'} + 1;
$offset = $rec_limit * $page ;
}
else
{
$page = 0;
$offset = 0;
}
$left_rec = $rec_count - ($page * $rec_limit);
$sql = "SELECT fb, prenume, judet ".
"FROM utilizatori ".
"LIMIT $offset, $rec_limit";
$retval = mysql_query( $sql, $conn );
if(! $retval )
{
die('Could not get data: ' . mysql_error());
}
while($row = mysql_fetch_array($retval, MYSQL_ASSOC))
{
echo "<div id='whatever'>";
echo "<div><img width='96' height='96' src='https://graph.facebook.com/{$row['fb']}/picture?type=normal'>".
"</div>"; // afisarea rezultatului
}
if( $page > 0 )
{
$last = $page - 2;
echo "</div>";
echo "<br/><br/><a href=\"$_PHP_SELF?page=$last\">Last 10 Records</a> |";
echo "<a href=\"$_PHP_SELF?page=$page\">Next 10 Records</a>";
}
else if( $page == 0 )
{
echo "<br/><br/><a href=\"$_PHP_SELF?page=$page\">Next 10 Records</a>";
}
else if( $left_rec < $rec_limit )
{
$last = $page - 2;
echo "<br/><br/><<a href=\"$_PHP_SELF?page=$last\">Last 10 Records</a>";
}
mysql_close($conn);
?>
Am incearcat si cu table dar tot asa imi afiseaza.
Multumesc de ajutor!