47 |
$sql_where.=" and id=$id "; |
$sql_where.=" and id=$id "; |
48 |
} |
} |
49 |
|
|
50 |
$sth = $dbh->prepare("select id,title,town_date,body,more,pdf from news $sql_where order by id desc"); |
if (isset($type)) { |
51 |
|
if ($type == "n") { |
52 |
|
$sql_where .= " and type='n'"; |
53 |
|
} elseif ($type == "e") { |
54 |
|
$sql_where .= " and type='e'"; |
55 |
|
} |
56 |
|
} |
57 |
|
|
58 |
|
if (! isset($show) && !isset($start)) { |
59 |
|
$sql_limit="limit 10"; |
60 |
|
} elseif (isset($start)) { |
61 |
|
$sql_limit="limit 10,$start"; |
62 |
|
} |
63 |
|
|
64 |
|
|
65 |
|
$num_selected=0; |
66 |
|
$sql="select |
67 |
|
id,upper(title) as title,town_date,body,more,pdf, |
68 |
|
(date-now()::date) as comming |
69 |
|
from news $sql_where order by priority desc,date desc $sql_limit"; |
70 |
|
print "$sql"; |
71 |
|
$sth = $dbh->prepare("$sql"); |
72 |
$sth->execute(); |
$sth->execute(); |
73 |
while ($row=$sth->fetchrow_hash()) { |
while ($row=$sth->fetchrow_hash()) { |
74 |
$data[]=$row; |
$data[]=$row; |
75 |
|
$num_selected++; |
76 |
|
} |
77 |
|
|
78 |
|
if ($num_selected == 10) { |
79 |
|
$smarty->assign(array( |
80 |
|
"multi_page_show" => 1, |
81 |
|
"multi_page_next" => "$PHP_SELF?start=".($start+10), |
82 |
|
)); |
83 |
|
} |
84 |
|
if ($start && $start >= 10) { |
85 |
|
$smarty->assign(array( |
86 |
|
"multi_page_show" => 1, |
87 |
|
"multi_page_prev" => "$PHP_SELF?start=".($start-10), |
88 |
|
)); |
89 |
} |
} |
90 |
|
|
91 |
$smarty->assign("data",$data); |
$smarty->assign("data",$data); |