/[health_html]/inc/newsShow.php
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /inc/newsShow.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by ravilov, Fri Aug 3 11:21:16 2001 UTC revision 1.3 by ravilov, Tue Aug 7 13:55:51 2001 UTC
# Line 2  Line 2 
2          function newsLoad($id, $cat, $limit = 1, $npar = 1) {          function newsLoad($id, $cat, $limit = 1, $npar = 1) {
3                  global $dbh;                  global $dbh;
4                  $arts = array();                  $arts = array();
5                  $sql = "SELECT news_id, title, lead, title_pic, title_alt, title_pos, url, date FROM news WHERE (category = '$cat')";                  $sql = "SELECT news_id, title, lead, title_pic, title_alt, title_pos, url, date, ord FROM news WHERE (category = '$cat')";
6                  if ($id > 0) $sql .= " AND (news_id = $id)";                  if ($id > 0) $sql .= " AND (news_id = $id)";
7                  $sql .= " ORDER BY date DESC LIMIT $limit";                  $sql .= " ORDER BY date DESC LIMIT $limit";
8                  $sth = $dbh->prepare($sql);                  $sth = $dbh->prepare($sql);
# Line 11  Line 11 
11                  while ($row = $sth->fetchrow_array()) {                  while ($row = $sth->fetchrow_array()) {
12                          $art = array();                          $art = array();
13                          list($art["id"], $art["title"], $art["lead"], $art["pic_url"],                          list($art["id"], $art["title"], $art["lead"], $art["pic_url"],
14                                  $art["pic_alt"], $art["pic_pos"], $art["more"], $date) = $row;                                  $art["pic_alt"], $art["pic_pos"], $art["more"],
15                                    $date, $ord) = $row;
16                          list($art["pic_w"], $art["pic_h"]) = PicSize($art["pic"]);                          list($art["pic_w"], $art["pic_h"]) = PicSize($art["pic"]);
17                          $text = array();                          $text = array();
18                          if (isset($art["id"])) {                          if (isset($art["id"])) {
# Line 37  Line 38 
38                                  $sth2->finish();                                  $sth2->finish();
39                          }                          }
40                          $art["text"] = $text;                          $art["text"] = $text;
41                            $art["order"] = $ord;
42                          $art["read"] = (count($art["text"]) > $npar) ? true : false;                          $art["read"] = (count($art["text"]) > $npar) ? true : false;
43                          $art["category"] = $cat;                          $art["category"] = $cat;
44                          $art["limit"] = $limit;                          $art["limit"] = $limit;
# Line 44  Line 46 
46                          array_push($arts, $art);                          array_push($arts, $art);
47                  }                  }
48                  $sth->finish();                  $sth->finish();
49                    $foo = true;
50                    while ($foo) {
51                            $foo = false;
52                            for ($i = 0; $i < count($arts); $i++) {
53                                    if ($arts[$i]["order"] == 0) continue;
54                                    $j = ($i + $arts[$i]["order"]);
55                                    $j %= count($arts);
56                                    $foo = true;
57                                    $tmp = $arts[$j];
58                                    $arts[$j] = $arts[$i];
59                                    $arts[$i] = $tmp;
60                                    $arts[$j]["order"] = 0;
61                            }
62                    }
63                  return $arts;                  return $arts;
64          }          }
65    

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

  ViewVC Help
Powered by ViewVC 1.1.26