Location: PHPKode > projects > MeBiblio > meBiblio-0.4.8/pacs_view_searched.inc.php
  <? 
      include "dblink.php";

     //print "Author ".$_POST['Author']; 
      if ( 
      		($_POST['PACS_description'] ==NULL ) && 
      		($_POST['PACS'] ==NULL )  

      ) {$where = "1 > 0 ";
      }
      else {
      $where_index=0;
       if ($_POST['PACS_description'] != NULL){
	$where = "PACS_description LIKE '%".$_POST['PACS_description']."%'";
	$where_index=1;
	}


       elseif ($_POST['PACS'] != NULL){
	$where = "PACS = \"".$_POST['PACS']."\"";
	$where_index=1;
	}
	}

	if ($_GET['where']) $where = $_GET['where']; 
	$ORDERBY="PACS_ID";
	//print "Order BY ".$ORDERBY;
      print "where : $where <p>index $where_index";

      $WHERE=stripslashes($where);

      $sql = "SELECT PACS , PACS_description FROM PACS WHERE ".$WHERE." 
      ORDER BY ".$ORDERBY;  

      print "<p> QUERY: $sql<br>";
      
      $result = mysql_query($sql) or die("Invalid query: " . mysql_error());
	
      $num = mysql_num_rows($result);

      $NumberOfPages = intval($num/$DisplayNumber);
?>
   <p><? print "$ViewSelectedBibliography: $NumberOfPages pages of results.<p>";?>
   
   <table>

<?
# try to get page number param from querystring
	$page=1;
	if ($_GET['page']) {
	//	 if (intval($_GET['page']) > 0 and intval($_GET['page']) <= $NumberOfPages)
			 $page = intval($_GET['page']);
	}
//put the link to previous or next page

if ($page > 1 ) {
	$previous = $page - 1;
	$navbar .= "\t\t\t\t<a
	href=\"".$_SERVER["PHP_SELF"]."?action=pacs_view_searched&amp;page=$previous&amp;where=$WHERE\"> &laquo;$LabelPreviousPage</a>  \n";
} else {
	$navbar .= "\t\t\t\t&nbsp;\n";
}

//print "page";
$navbar=$navbar."Page $page";

# next page link (if actual page < lastpage)
if ($page < $NumberOfPages) {
	$next = $page + 1;
	$navbar .= "\t\t\t\t<a href=\"".$_SERVER["PHP_SELF"]."?action=pacs_view_searched&amp;page=$next&amp;where=$WHERE\">$LabelNextPage &raquo;</a>\n";
} else {
	$navbar .= "\t\t\t\t&nbsp;\n";
}
print $navbar;
# calculate array index of first reference to display in this page
# display pages of 20 rows

      $FirstReference = ($page-1)*$DisplayNumber;
      $LastReference = min ($FirstReference+$DisplayNumber,$num);

     // print "First reference ".$FirstReference." Last ".$LastReference;

      for ($i=$FirstReference;$i<$LastReference;$i++ ){
      
        mysql_data_seek($result,$i);
        $field = mysql_fetch_row($result);
	
	//display result
	$bgcolor = "#000000";           
                if ($i%2==0)
                        $bgcolor = "#222222";
	print "	
		\t<tr><td valign=top bgcolor=\"$bgcolor\">$field[0]</td>
		\t<td valign=top bgcolor=\"$bgcolor\" width=\"700\"><i>$field[1]</i></td>
		";
      }


      mysql_close($link);
?>
   </table>
Return current item: MeBiblio