set($row); $tpl->set("href", href("survey", 0, $row['sur_id']), 'bg', $news_bg[$i++ % $N], 'no', $i); make_item_dt($tpl, $row['dt']); $y1 = date('Y', $row['dt']); if (isset($y0) && $y1 < $y0) $tpl->parse("surv_hr", ".surv_row"); $tpl->parse("surv_row", ".surv_row"); $y0 = $y1; } @mysql_free_result($res); $tpl->parse("list", "list"); cache_store($tpl, "list"); } /* selected survey results */ if (!$REQ['sur']) $REQ['sur'] = $sur['sur_id']; /* tmp!!! */ if ($REQ['sur'] > 0) { $res = mysql_query("SELECT sur_id, sur_title, sur_text, UNIX_TIMESTAMP(sur_date) AS dt FROM survey WHERE sur_id=$REQ[sur] AND sur_vis=1 AND sur_lang=$lang"); $sur = @mysql_fetch_array($res); @mysql_free_result($res); if (is_array($sur)) { $parse_surr_box = true; if (survey_results($REQ['sur'], $_POST['survey2'], $_POST['vote2'])) $parse_surr_box = false; $page_title = $sur['sur_title']; $res = mysql_query("SELECT SUM(surr_count) FROM survey_r WHERE surr_sid=$sur[sur_id]"); list($sum) = @mysql_fetch_row($res); @mysql_free_result($res); $res = mysql_query("SELECT surq_id, surq_text, surr_count FROM survey_q LEFT JOIN survey_r ON surq_id=surr_qid WHERE surq_sur=$sur[sur_id] ORDER BY surq_pos"); $total_count = 100; while ($row = mysql_fetch_array($res)) { $perc = $sum ? number_format((100*$row['surr_count']/$sum),1) : 0; //$perc = $sum ? 100*$row['surr_count']/$sum,2) : 0; $tpl->set($row); $tpl->set("perc", $perc, "img", "\"$perc"); $tpl->parse("surr_row", ".surr_row"); $tpl->parse("surr_box_row", ".surr_box_row"); } @mysql_free_result($res); $tpl->set($sur); make_item_dt($tpl, $sur['dt']); $tpl->set("sur_votes", $sum); if ($parse_surr_box) $tpl->parse("surr_box", "surr_box"); if ($already_voted) $tpl->parse("surr_already", "surr_already"); $tpl->parse("surr", "surr"); } } $tpl->parse("main", "main"); ?> CYPRUS MIRROR Daily News |