Phorum.ro
Your Avatar Welcome to Phorum.ro!
If you haven't registered yet, click here!
Attention Visitor:
You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.
Du-te înapoi   Phorum.ro > Web Design & Web Development > Programare > PHP > PHP DB

PHP DB Discutii despre lucrul cu baze de date in PHP.

Răspunde
 
Thread Tools Moduri de afișare
Vechi 11.08.2007   #1
FnatiK
32-Bit Member
 
FnatiK's Avatar
 
Data înregistrării: 24.09.2006
Locație: Turda/Romania
Mesaje: 167
Rep Power: 6
FnatiK is on a distinguished road
Trimite un mesaj prin Yahoo pentru FnatiK
Implicit Ajutor

Folosesc un script de paginare din DB si merge perfect . problema e ca atunci cand inserez date noi in baza de date mi le afiseaza la coada . De exemplu :
daca am 5 rezultate afisate pe prima pagina si adaug o intrare in DB mio afiseaza pe a doua pagina(asta in cazul in care pagina e limitata la 5 randuri) .

Aici e codul :

Cod PHP:
<?php
include 'conexiune.php';


$rowsPerPage 5;
$pageNum 1;


if(isset(
$_GET['page']))
{
    
$pageNum $_GET['page'];
}

// counting the offset
$offset = ($pageNum 1) * $rowsPerPage;

$query  "SELECT id, title, descriere
           FROM news "
;
           
$pagingQuery "LIMIT $offset, $rowsPerPage";
$result mysql_query($query $pagingQuery) or die('Eroare,query-ul a dat gres');


while(list(
$id$title$descriere) = mysql_fetch_array($result))
{
echo 
"<div class=\"stirilezilei\"><a href=\"articole.php?id=$id\" title=\"$title\" class=\"stirilezilei\">$title</a><div style=\"font-family:Verdana ;font-size:11px;font-weight:normal;\">$descriere... [<a href=\"articole.php?id=$id\" title=\"$title\">continuare</a>]</div></div>";
}

$result  mysql_query($query) or die('Error, query failed');
$numrows mysql_num_rows($result);

$maxPage ceil($numrows/$rowsPerPage);

$self $_SERVER['PHP_SELF'];


if (
$pageNum 1)
{
    
$page $pageNum 1;
    
$prev " <a href=\"$self?page=$page\">[back]</a> ";

    
$first " <a href=\"$self?page=1\">[prima]</a> ";
}
else
{
    
$prev  ' [back] ';    
    
$first ' [prima] ';
}

if (
$pageNum $maxPage)
{
    
$page $pageNum 1;
    
$next " <a href=\"$self?page=$page\">[next]</a> ";

    
$last " <a href=\"$self?page=$maxPage\">[ultima]</a> ";
}
else
{
    
$next ' [next] ';
    
$last ' [ultima] ';
}

echo 
"<div class=\"inapoi_sus_articolul_zilei\"><small>$first . $prev . <strong>$pageNum</strong> din <strong>$maxPage</strong> . $next . $last</small></div>";

?>
As vrea ca intrarile mai recente sa fie afisate pe prima pagina . Pls ajutor
__________________
-E o lume magica dar tragica din cauza unor pasarici!
*http://webdesign.wazup.ro/
*http://cs.wazup.ro/
FnatiK is offline   Reply With Quote
Sponsored Links
Vechi 11.08.2007   #2
FnatiK
32-Bit Member
 
FnatiK's Avatar
 
Data înregistrării: 24.09.2006
Locație: Turda/Romania
Mesaje: 167
Rep Power: 6
FnatiK is on a distinguished road
Trimite un mesaj prin Yahoo pentru FnatiK
Implicit Rezolvat

Newer mind . Am descoperit .

Cod PHP:
$query  "SELECT id, title, descriere
           FROM news ORDER BY id DESC "

ORDER BY id DESC
__________________
-E o lume magica dar tragica din cauza unor pasarici!
*http://webdesign.wazup.ro/
*http://cs.wazup.ro/
FnatiK is offline   Reply With Quote
Răspunde


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Moduri de afișare

Reguli de postare
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is Pornit
emoticoanele sunt Pornit
Codul [IMG] este Pornit
Codul HTML este Oprit



Ora este GMT +3. Ora este acum 00:21:18.


Rulează cu: vBulletin Version 3.8.4
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Forum SEO by Zoints

XXXXXXXXXXXXXXXXXXX
Inactive Reminders By Icora Web Design