--- new.php 2001/02/22 20:51:10 1.4 +++ new.php 2001/02/23 15:23:32 1.5 @@ -47,10 +47,43 @@ $sql_where.=" and id=$id "; } - $sth = $dbh->prepare("select id,upper(title) as title,town_date,body,more,pdf from news $sql_where order by date desc"); + if (isset($type)) { + if ($type == "n") { + $sql_where .= " and type='n'"; + } + } + + if (! isset($show) && !isset($start)) { + $sql_limit="limit 10"; + } elseif (isset($start)) { + $sql_limit="limit 10,$start"; + } + + + $num_selected=0; + $sql="select + id,upper(title) as title,town_date,body,more,pdf, + (date-now()::date) as comming + from news $sql_where order by date desc $sql_limit"; +# print "$sql"; + $sth = $dbh->prepare("$sql"); $sth->execute(); while ($row=$sth->fetchrow_hash()) { $data[]=$row; + $num_selected++; + } + + if ($num_selected == 10) { + $smarty->assign(array( + "multi_page_show" => 1, + "multi_page_next" => "$PHP_SELF?start=".($start+10), + )); + } + if ($start && $start >= 10) { + $smarty->assign(array( + "multi_page_show" => 1, + "multi_page_prev" => "$PHP_SELF?start=".($start-10), + )); } $smarty->assign("data",$data);