$sql="select title,alt_name,short_story,pic,id_nomer from news where id_nomer=(select id from nomera where active=true order by dt desc limit 1) order by sort limit 7";
$res=pg_query($dbh,$sql);
print '
$sql="select a.title,a.alt_name,b.id,b.dt from news a left join nomera b on b.id=a.id_nomer where b.active=true and b.dt>now()-interval '2 month' order by a.news_read desc limit 7";
$res=pg_query($dbh,$sql);
while ($row=pg_fetch_row($res)) {
print '
if (isset($_COOKIE['already_answered'])) {
$sql="select * from opros where opened=true and id not in (".implode(",",$_COOKIE['already_answered']).") order by date_from limit 1";
} else {
$sql="select * from opros where opened=true order by date_from limit 1";
}
$res=pg_query($dbh,$sql);
?>
Ваше мнение
if ($row=pg_fetch_row($res)) {
?>
животноводство, сводка, весенний, полевые работы, намолот, зерно
} else if (isset($_COOKIE['already_answered'])) {
$sql="select * from opros where id in (".implode(",",$_COOKIE['already_answered']).") order by date_from limit 1";
$res=pg_query($dbh,$sql);
$row=pg_fetch_row($res);
print "
".$row[1]."
";
$sql="select res,num from responses where id_question='".$row[0]."' order by id";
$res=pg_query($dbh,$sql);
$i=0;
while ($row=pg_fetch_row($res)) {
$otvet[$i]=$row[0];
$summa[$i]=$row[1];
$i++;
}
$maxsum=max($summa);
$allsum=array_sum($summa);
for ($j=0;$j<$i;$j++) {
print $otvet[$j]."";
print "