Am o baza de date structurata astfel:
Cod: Selectaţi tot
id url embed_url title duration date_added thumb1 thumb2 ... thumb10 categories
1 link1 embed_link title1 values in seconds yyyy-mm-dd link_thumb1 link_thumb1 link_thumb1 category1,category2
Cod: Selectaţi tot
<?php
$my_timer = microtime();
$time_parts = explode(' ', $my_timer);
$time_right_now = $time_parts[1] + $time_parts[0];
$starting_time = $time_right_now;
include 'config.php';
define('CSSPATH', '');
$cssItem = 'styles.css';
?>
<!DOCTYPE html>
<html>
<head>
<title><?php echo $title; ?></title>
<link rel="stylesheet" type="text/css" href="<?php echo (CSSPATH . "$cssItem"); ?>">
</head>
<body>
<div class="header">
<div class="container">
<div class="logo">
<h1><a href="#"><span style="color:#840607;">NU</span><span class="style4">Conteaza<sup>Beta</sup></span></a></h1>
</div>
</div>
</div>
<!--- <div class="left">
<p>menu</p>
<p>menu</p><p>menu</p>
<p>menu</p>
<p>menu</p><p>u</p>
</div>--->
<div class="container">
<div class="content">
<?php
$conn = mysql_connect($host, $utilizator, $parola);
if (!$conn) {
echo 'Conectare nereusita la MySQL';
exit;
}
if (!mysql_select_db($numebd, $conn)) {
echo 'Baza de date nu a putut fi selectata deoarece : '. mysql_error();
exit;
}
$sql = "SET NAMES 'utf8'";
mysql_query($sql, $conn);
$sql = "SELECT COUNT(*) FROM `nuconteaza`";
$result = mysql_query($sql, $conn) or trigger_error(E_USER_ERROR);
$r = mysql_fetch_row($result);
$numrows = $r[0];
$rowsperpage = 50;
$totalpages = ceil($numrows / $rowsperpage);
if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) {
$currentpage = (int) $_GET['currentpage'];
} else {
$currentpage = 1;
}
if ($currentpage > $totalpages) {
$currentpage = $totalpages;
}
if ($currentpage < 1) {
$currentpage = 1;
}
$offset = ($currentpage - 1) * $rowsperpage;
$sql = "SELECT id, url, thumb1 FROM `nuconteaza` ORDER BY date_added DESC LIMIT $offset, $rowsperpage";
$result = mysql_query($sql, $conn) or trigger_error(E_USER_ERROR);
$re_out ='';
$i =0;
while ($list = mysql_fetch_assoc($result)) {
$id[] = $list['id'];
$url[] = $list['url'];
//$embed_url[] = $list['embed_url'];
//$description[] = $list['description'];
//$duration[] = $list['duration'];
//$date_added[] = $list['date_added'];
$thumb1[] = $list['thumb1'];
//$thumb2[] = $list['thumb2'];
//$thumb3[] = $list['thumb3'];
//$thumb4[] = $list['thumb4'];
//$thumb5[] = $list['thumb5'];
//$thumb6[] = $list['thumb6'];
//$thumb7[] = $list['thumb7'];
//$thumb8[] = $list['thumb8'];
//$thumb9[] = $list['thumb9'];
//$thumb10[] = $list['thumb10'];
//$categories[] = $list['categories'];
//$views_count[] = $list['views_count'];
$re_out .='<a href="'.$list["url"].'" target="_blank" class="padre"><img src="'.$list["thumb1"].'" style="width:160px;height:120px" >';
$i++;
if(($i%5)==0) $re_out .='<br>';
}
mysql_close();
echo $re_out ;
$range = 3;
if ($currentpage > 0) {
echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=1'><<</a> ";
$prevpage = $currentpage - 1;
echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage'><</a> ";
}
for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) {
if (($x > 0) && ($x <= $totalpages)) {
if ($x == $currentpage) {
echo " [<b>$x</b>] ";
} else {
echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$x'>$x</a> ";
}
}
}
if ($currentpage != $totalpages) {
$nextpage = $currentpage + 1;
echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage'>></a> ";
echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$totalpages'>>></a> ";
}
$my_timer = microtime();
$time_parts = explode(' ', $my_timer);
$time_right_now = $time_parts[1] + $time_parts[0];
$finishing_time = $time_right_now;
$total_time_in_secs = round(($finishing_time - $starting_time), 4);
echo 'Page generated in '.$total_time_in_secs.' seconds.';
?>
</div>
<div class="footer">
</div>
</div>
</body>
</html>
PS. Inca lucrez pe 127.0.0.1 (localhost). nu gasesc nici un serviciu de gazduire gratis care sa imi urce toata baza de date.
Un pic de ajutor va rog