/[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.3 by ravilov, Tue Aug 7 13:55:51 2001 UTC revision 1.4 by ravilov, Wed Aug 8 12:58:08 2001 UTC
# Line 1  Line 1 
1  <?php  <?php
2          function newsLoad($id, $cat, $limit = 1, $npar = 1) {          function newsLoad($id, $cat, $limit = 1, $offset = 0, $npar = 1) {
3                  global $dbh;                  global $dbh;
4                  $arts = array();                  $arts = array();
5                    if (!$offset) $offset = 0;
6                  $sql = "SELECT news_id, title, lead, title_pic, title_alt, title_pos, url, date, ord 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')";
7                  if ($id > 0) $sql .= " AND (news_id = $id)";                  if ($id > 0) $sql .= " AND (news_id = $id)";
8                  $sql .= " ORDER BY date DESC LIMIT $limit";                  $sql .= " ORDER BY date DESC";
9                    if ($limit) $sql .= " LIMIT $limit OFFSET $offset";
10                  $sth = $dbh->prepare($sql);                  $sth = $dbh->prepare($sql);
11                  if (!$sth) error("Cannot prepare query: \"$sql\"");                  if (!$sth) error("Cannot prepare query: \"$sql\"");
12                  if (!$sth->execute()) error("Cannot execute query: \"$sql\"");                  if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
# Line 42  Line 44 
44                          $art["read"] = (count($art["text"]) > $npar) ? true : false;                          $art["read"] = (count($art["text"]) > $npar) ? true : false;
45                          $art["category"] = $cat;                          $art["category"] = $cat;
46                          $art["limit"] = $limit;                          $art["limit"] = $limit;
47                            $art["offset"] = $offset;
48                          $art["npar"] = $npar;                          $art["npar"] = $npar;
49                          array_push($arts, $art);                          array_push($arts, $art);
50                  }                  }

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

  ViewVC Help
Powered by ViewVC 1.1.26