Segregowanie

2010-12-15 20:48:05 Post #1 Pudi

 
Witam mam problem ponieważ wszystkie newsy w serwisie po dodaniu paginatora wyświetlają mi się od końca(od najstarszego do najnowszego) chciałbym by wszystko wyświetlało się normalnie ze dodam newsa to jest na początku a nie na szarym końcu kod:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
        <?php
include('config.php');
include(
'include/bbcode.php'); 
require_once(
'Pager.class.php');

$sql 'select count(*) from news';
$result mysql_query($sql)  or die(mysql_error());
$row mysql_fetch_array($result);
$recordsCount $row[0];//pobranie liczby rekordów
try{
    
$pager = new Pager('id');
    
$pager->SetTotalRecords($recordsCount);
    
$pager->SetRecordsPerPage(2); 
    
$pager->Make(true);
    
$pag $pager->Render();
    
$start $pager->GetIndexRecordStart();
    
$end $pager->GetIndexRecordEnd();
}
catch (
Exception $e) {
    echo 
$e->getMessage();
}

//zapytanie z uwzglenieniem stronicowania
$sql 'select * from news  limit '.$start.','.($end $start 1);
$result mysql_query($sql) or die(mysql_error());
if(
$result){ 
while(
$row mysql_fetch_array($result)){ 
echo
'<table cellpadding="0" cellspacing="0" >
<tr><td class="m2">'
;
echo 
$row['tytul']; 
echo 
'</td></tr><tr><td width="390"><div class="brd"><div class="newsy">';
echo 
bbcode($row['tresc']);
echo 
'<hr>Dodal: '
echo 
$row['login'];
echo 
' Dnia: '
echo 
$row['data']; 
echo 
'</div></td></tr></table><br>';    


else { 
echo 
'Nic nie znalazlem'
}     
echo 
'<br><center>';
echo 
$pag;//wyswietlenie pager'a
echo '</center>';
?>

2010-12-15 20:51:59 Post #2 Comandeer

 
1
$sql = 'select * from news  limit '.$start.','.($end - $start + 1).' order by data desc';

Proponuję poczytać sobie o systemach szablonów i klasie mysqli (jak jesteś ambitny to o PDO, jak super ambitny to o bazach NOSQL )

2010-12-15 21:11:46 Post #3 Pudi

 
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order by data desc' at line 1

Taki eror ;/

2010-12-15 21:15:05 Post #4 Comandeer

 
No, fajny error. Nie wiem o co się rzuca, ale chyba o to, że limit ma być na końcu. Sprawdź z tym
1
$sql = 'select * from news order by data desc  limit '.$start.','.($end - $start + 1).';

2010-12-15 21:19:24 Post #5 Pudi

 
1
2
3
4
$sql = 'select * from news order by data desc  limit '.$start.','.($end - $start + 1).';
bez .'
$sql = 'select * from news order by data desc  limit '.$start.','.($end - $start + 1);

Dzięki wielkie
o szablonach myślałem ale nie kumam tego tpl

2010-12-15 21:21:40 Post #6 Comandeer

 
Początkowo trudno się przestawić, ale jak już się uda to praca z TPL to czysta przyjemność. Osobiście polecam PHPTAL

Odpowiedz