get_results("select * from peb_bulletins ORDER BY year DESC, number"); $bulletins = array(); foreach ( $db_bulletins as $b ) { $bulletins[$b->peb_id] = array ("year" => $b->year, "volume" => $b->volume, "number" => $b->number); } foreach ($db_articles as $a) { print ""; print ""; print ""; print ""; print ""; print ""; } print "

PEB Vol.

Author

Title

View

".$bulletins[$a->peb_id]["year"].", ".$bulletins[$a->peb_id]["volume"]." (".$bulletins[$a->peb_id]["number"].")

".$a->author."

".$a->title."

"; if ($a->abstract!=NULL) print "

[ art_id\">View Abstract ]

"; if ($a->url!=NULL) print "

[ url."\" target=\"_blank\">View PDF ]

"; print "
"; } /* SQL QUERY CLASS */ class sqlQuery { // Just an object used to simplify building an sql query made of many 'AND' clauses... might get extended later. var $select; var $whereClauses = array(); var $orderBy; function addSELECT($s) { $this->select = "SELECT ".$s." "; } function addWHERE($clause) { array_push($this->whereClauses, $clause); } function addORDERBY($s) { $this->orderBy = "ORDER BY ".$s; } function sqlToString(){ $sqlOut = "".$this->select; if (count($this->whereClauses)>0) { $sqlOut .= "WHERE "; $i = 0; foreach($this->whereClauses as $c) { $sqlOut .= $c; $i++; if ($i < count($this->whereClauses)) $sqlOut.=" AND "; } } $sqlOut .= " ".$this->groupBY; return $sqlOut; } } ?>

 

Search Bulletins

addSELECT("* FROM peb_articles"); if (isset($filterTable)) { // They've chosen to filter their view... we just need to amend the sql query appropriately if ($peb_id!="all") $query->addWHERE("peb_id=".$peb_id); if ($article_type!="all") $query->addWHERE("type='$article_type'"); $searchText = split(" ",$search); foreach($searchText as $s) { $query->addWHERE("(author LIKE '%$s%' OR title LIKE '%$s%' OR abstract LIKE '%$s%')"); } $query->addORDERBY("peb_id"); $sqlString = $query->sqlToString(); if ($selected_articles = $db->get_results($sqlString)) { printArticleTable($selected_articles); } else { print "Search returned no results"; } } else { // They haven't searched for anything yet print ""; } ?>