Autor Zpráva
divady
Profil
Dobrý den, potřeboval bych poradít. chtěl bych rozdělit seznam aby se zobrazoval na více stránek.
ten seznam ne tvořenej ze zobrazení několika položek. tady je adresa .. http://www.srovnejokna.cz/poptavky
const pzn=33;

$sql=new mysql();


$c_arr = array();
$c_buf = '';

$c_zak = $sql->arrays("SELECT * from vz WHERE vlozeno > DATE(NOW()) ORDER BY ID DESC");
$c_pop = $sql->arrays("SELECT * from poptavky WHERE zalozeno > DATE(NOW()) ORDER BY ID DESC");


if ($c_zak) {
   $c_format = '%s, za %s&nbspKÄŤ - %s';

   foreach ($c_zak as $key => $value) {
      array_push($c_arr,
         sprintf($c_format, c_strip_str_len($value[nazev], pzn),
            c_nf($value[cena]),
            $value[mesto]
         )
      );
   }


}

if ($c_pop) {
   $c_format = '%s, za %s&nbspKÄŤ';

   foreach ($c_pop as $key => $value) {
      array_push($c_arr,
         sprintf($c_format, c_strip_str_len($value[label], pzn),
            c_nf($value[cena])
         )
      );
   }
}

shuffle($c_arr);

$c_format = '<a href="/poptavky/">%s...</a>&nbsp;&nbsp;';

foreach ($c_arr as $key => $value) {
      $c_buf .= sprintf($c_format, $value);
}

$fce[c_banner_poptavky] = $c_buf;

// BANNER ---

//$q=$sql->arrays("SELECT * from vz ORDER BY ID DESC LIMIT 0,8");
$q=$sql->arrays("SELECT * from vz WHERE vlozeno < DATE(NOW()) ORDER BY ID DESC LIMIT 0,8");
if ($q) foreach ($q as $res){

if (date ("d.m.Y")==date("d.m.Y",strtotime("$res[vlozeno]"))) $dat="dnes";
elseif (date ("d.m.Y", strtotime("-1 day"))==date("d.m.Y",strtotime("$res[vlozeno]"))) $dat="vÄŤera";
else $dat=date("d.m.Y", strtotime("$res[vlozeno]")); 

if (strlen($res[nazev]) > pzn) $nazev=substr($res[nazev],0,pzn).'...'; else $nazev=$res[nazev];

$c_format = '%s, za %s&nbspKÄŤ - %s';
$anw.="<TR ROWSPAN=\"2\"><TD class=\"podtrh\"><A HREF = \"/poptavky/\">".
c_strip_str_len(sprintf($c_format, $res[nazev], c_nf($res[cena]), $res[mesto]), 120, '...')
."</A><TD class=\"datum\">$dat</TR>";
}
$fce[zakazky]=$anw;

$anw="";



$q=$sql->arrays("SELECT * from vz WHERE vlozeno > DATE_SUB(NOW(), INTERVAL 120 DAY) ORDER BY ID DESC");
if ($q) foreach ($q as $res){

if (date ("d.m.Y")==date("d.m.Y",strtotime("$res[vlozeno]"))) $dat="dnes";
elseif (date ("d.m.Y", strtotime("-1 day"))==date("d.m.Y",strtotime("$res[vlozeno]"))) $dat="vÄŤera";
else $dat=date("d.m.Y", strtotime("$res[vlozeno]")); 

$anw.="<TR><TD class=\"podtrh\"><A HREF = \"/zakazka-detail-$res[ID]/\">$res[nazev], za ".c_nf($res[cena])."&nbspKÄŤ<BR>$res[mesto]</A><TD class=\"datum\">$dat</TR>";
}
$fce[zakazky2]=$anw;

// ZAKÁZKY ---


$q=$sql->arrays("SELECT * from poptavky WHERE zalozeno > DATE_SUB(NOW(), INTERVAL 120 DAY) ORDER BY ID DESC");
if ($q) foreach ($q as $res){

if (date ("d.m.Y")==date("d.m.Y",strtotime("$res[zalozeno]"))) $dat="dnes";
elseif (date ("d.m.Y", strtotime("-1 day"))==date("d.m.Y",strtotime("$res[zalozeno]"))) $dat="vÄŤera";
else $dat=date("d.m.Y", strtotime("$res[zalozeno]")); 
if ($res[cena]=="0") $cena = "";
  else $cena = ", za ".c_nf($res[cena])."&nbspKÄŤ";

$pop.="<TR><TD class=\"datum\">$dat<TD class=\"podtrh\"><A HREF = \"/poptavka-detail-$res[ID]/\">$res[label]$cena</A></TR>";
}

$fce[poptavky2]=$pop;

$pop="";

//$q=$sql->arrays("SELECT * from poptavky ORDER BY ID DESC LIMIT 0,8");
$q=$sql->arrays("SELECT * from poptavky WHERE zalozeno < DATE(NOW()) ORDER BY ID DESC LIMIT 0,8");
if ($q) foreach ($q as $res){

if (date ("d.m.Y")==date("d.m.Y",strtotime("$res[zalozeno]"))) $dat="dnes";
elseif (date ("d.m.Y", strtotime("-1 day"))==date("d.m.Y",strtotime("$res[zalozeno]"))) $dat="vÄŤera";
else $dat=date("d.m.Y", strtotime("$res[zalozeno]")); 
  if ($res[cena]=="0") $cena = "";
  else $cena = ", za ".c_nf($res[cena])."&nbspKÄŤ";

if (strlen($res[label]) > pzn) $nazev=substr($res[label],0,pzn).'...'; else $nazev=$res[label];

$c_format = '%s%s';
$pop.="<TR><TD class=\"datum\">$dat<TD class=\"podtrh\"><A HREF = \"/poptavky/\">".
c_strip_str_len(sprintf($c_format, $nazev, $cena), 120, '...')
."</A></TR>";
}

return $pop;
zkoušel jsem to vyřešit takto
$pocet=10;



if ($_GET[stranka]) $stranka=$_GET[stranka];
else $stranka=1;

$page=($stranka-1)*$pocet;

$qp = new pager("SELECT * FROM poptavka WHERE zalozeno > DATE_SUB(NOW()),'stranka',$mysql->sql_connect);
$qp->PageSize = $pocet; 
$qp->PagerAlign = "center";

$qp->DataBind(); 

$firstLastMode = new FirstLastPagerMode(); 
$qp->AddPagerMode($firstLastMode); 
$prevNextMode = new PrevNextPagerMode(); 
$qp->AddPagerMode($prevNextMode); 
$neighbourMode = new NeighbourPagerMode(); 
$neighbourMode->NeighbourPagesCount = 1; 
$qp->AddPagerMode($neighbourMode); 

$q.=$qp->DrawPager();
ale nefunfovalo to.
chtěl bych aby se vzniklá tabulka rozdělila na více stránek třeba po 10 položek.
scheras
Profil *
Použijte v SQL dotazu LIMIT.
divady
Profil
už jsem pokročil a to takhle
<?
   $pocet=10;
if ($_GET[stranka]) $stranka=$_GET[stranka];
else $stranka=1;
$page=($stranka-1)*$pocet;
const pzn=33;
                
$sql=new mysql();


$c_arr = array();
$c_buf = '';

$c_zak = $sql->arrays("SELECT * from vz WHERE vlozeno > DATE(NOW()) ORDER BY ID DESC LIMIT $page,$pocet");
$c_pop = $sql->arrays("SELECT * from poptavky WHERE zalozeno > DATE(NOW()) ORDER BY ID DESC LIMIT $page,$pocet");


if ($c_zak) {
    $c_format = '%s, za %s&nbspKÄŤ - %s';

    foreach ($c_zak as $key => $value) {
        array_push($c_arr,
            sprintf($c_format, c_strip_str_len($value[nazev], pzn),
                c_nf($value[cena]),
                $value[mesto]
            )
        );
    }

    
}

if ($c_pop) {
    $c_format = '%s, za %s&nbspKÄŤ';

    foreach ($c_pop as $key => $value) {
        array_push($c_arr,
            sprintf($c_format, c_strip_str_len($value[label], pzn),
                c_nf($value[cena])
            )
        );
    }
}

shuffle($c_arr);

$c_format = '<a href="/poptavky/">%s...</a>&nbsp;&nbsp;';

foreach ($c_arr as $key => $value) {
        $c_buf .= sprintf($c_format, $value);
}

$fce[c_banner_poptavky] = $c_buf;

// BANNER ---

//$q=$sql->arrays("SELECT * from vz ORDER BY ID DESC LIMIT $page,$pocet");
$q=$sql->arrays("SELECT * from vz WHERE vlozeno < DATE(NOW()) ORDER BY ID DESC LIMIT $page,$pocet");
if ($q) foreach ($q as $res){

if (date ("d.m.Y")==date("d.m.Y",strtotime("$res[vlozeno]"))) $dat="dnes";
 elseif (date ("d.m.Y", strtotime("-1 day"))==date("d.m.Y",strtotime("$res[vlozeno]"))) $dat="vÄŤera";
 else $dat=date("d.m.Y", strtotime("$res[vlozeno]")); 

 if (strlen($res[nazev]) > pzn) $nazev=substr($res[nazev],0,pzn).'...'; else $nazev=$res[nazev];

$c_format = '%s, za %s&nbspKÄŤ - %s';
$anw.="<TR ROWSPAN=\"2\"><TD class=\"podtrh\"><A HREF = \"/poptavky/\">".
c_strip_str_len(sprintf($c_format, $res[nazev], c_nf($res[cena]), $res[mesto]), 120, '...')
."</A><TD class=\"datum\">$dat</TR>";
}
$fce[zakazky]=$anw;

$anw="";

 

$q=$sql->arrays("SELECT * from vz WHERE vlozeno > DATE_SUB(NOW(), INTERVAL 120 DAY) ORDER BY ID DESC LIMIT $page,$pocet");
if ($q) foreach ($q as $res){

if (date ("d.m.Y")==date("d.m.Y",strtotime("$res[vlozeno]"))) $dat="dnes";
 elseif (date ("d.m.Y", strtotime("-1 day"))==date("d.m.Y",strtotime("$res[vlozeno]"))) $dat="vÄŤera";
 else $dat=date("d.m.Y", strtotime("$res[vlozeno]")); 

$anw.="<TR><TD class=\"podtrh\"><A HREF = \"/zakazka-detail-$res[ID]/\">$res[nazev], za ".c_nf($res[cena])."&nbspKÄŤ<BR>$res[mesto]</A><TD class=\"datum\">$dat</TR>";
}
$fce[zakazky2]=$anw;

// ZAKÁZKY ---


$q=$sql->arrays("SELECT * from poptavky WHERE zalozeno > DATE_SUB(NOW(), INTERVAL 120 DAY) ORDER BY ID DESC LIMIT $page,$pocet");
if ($q) foreach ($q as $res){

 if (date ("d.m.Y")==date("d.m.Y",strtotime("$res[zalozeno]"))) $dat="dnes";
 elseif (date ("d.m.Y", strtotime("-1 day"))==date("d.m.Y",strtotime("$res[zalozeno]"))) $dat="vÄŤera";
 else $dat=date("d.m.Y", strtotime("$res[zalozeno]")); 
 if ($res[cena]=="0") $cena = "";
  else $cena = ", za ".c_nf($res[cena])."&nbspKÄŤ";

 $pop.="<TR><TD class=\"datum\">$dat<TD class=\"podtrh\"><A HREF = \"/poptavka-detail-$res[ID]/\">$res[label]$cena</A></TR>";
}

$fce[poptavky2]=$pop;

$pop="";

//$q=$sql->arrays("SELECT * from poptavky ORDER BY ID DESC LIMIT $page,$pocet");
$q=$sql->arrays("SELECT * from poptavky WHERE zalozeno < DATE(NOW()) ORDER BY ID DESC LIMIT $page,$pocet");
if ($q) foreach ($q as $res){

 if (date ("d.m.Y")==date("d.m.Y",strtotime("$res[zalozeno]"))) $dat="dnes";
 elseif (date ("d.m.Y", strtotime("-1 day"))==date("d.m.Y",strtotime("$res[zalozeno]"))) $dat="vÄŤera";
 else $dat=date("d.m.Y", strtotime("$res[zalozeno]")); 
  if ($res[cena]=="0") $cena = "";
  else $cena = ", za ".c_nf($res[cena])."&nbspKÄŤ";
 
if (strlen($res[label]) > pzn) $nazev=substr($res[label],0,pzn).'...'; else $nazev=$res[label];

$c_format = '%s%s';
 $pop.="<TR><TD class=\"datum\">$dat<TD class=\"podtrh\"><A HREF = \"/poptavky/\">".
c_strip_str_len(sprintf($c_format, $nazev, $cena), 120, '...')
 ."</A></TR>";
}

return $pop;



// POPTÁVKY ----



?>
jen nevim kam mam dát
$qp = new pager("SELECT * FROM poptavky ORDER BY ID DESC",'stranka',$this->sql->sql_connect);
$qp->PageSize = $pocet; 
$qp->PagerAlign = "center";
$qp->DataBind();
echo $qp->DrawPager();
ale když to tam dám, tak se stránka pak ani nenačte, nevím kam to mam umístit

Vaše odpověď

Mohlo by se hodit


Prosím používejte diakritiku a interpunkci.

Ochrana proti spamu. Napište prosím číslo dvě-sta čtyřicet-sedm: