|
|
(4 versions intermédiaires par le même utilisateur non affichées) |
Ligne 1 : |
Ligne 1 : |
− | 'Test du PHPoutput2 | + | Cette page permet d'effectuer des recherches dans les bases de données Ebior ''<span style="color: #ff0000">'''en version Beta'''</span>''. |
− |
| |
− | <addhtml> | |
| | | |
− | <?php | + | ''<span style="color: #ff0000">Les résultats des recherches et les écrans affichés peuvent ne pas être corrects.</span>'' |
| | | |
− | // Get the search variable from URL
| + | <br> |
− | $var = @$_GET['q'] ;
| |
− | $s = @$_GET['s'] ;
| |
| | | |
− | $trimmed = trim($var); //trim whitespace from the stored variable
| + | <br> |
| | | |
− | // rows to return | + | {| border="1" cellspacing="1" cellpadding="1" |
| + | |- |
| + | ! scope="col" | Base de données |
| + | ! scope="col" | Description |
| + | ! scope="col" | Statut |
| + | |- |
| + | | [[Sophonie DB2|Sophonie]] |
| + | | Informations bibliques générales |
| + | | En <span style="background-color: rgb(0,255,0)">activité</span> |
| + | |- |
| + | | [[Jonas_DB2|''Jonas'']] 2 |
| + | | ''Calendrier liturgique'' |
| + | | En test |
| + | |- |
| + | | ''Amos'' |
| + | | ''Dictionnaire thématique du Nouveau Testament'' |
| + | | En préparation |
| + | |- |
| + | | ''Zacharie'' |
| + | | ''Synopse informatique'' |
| + | | En préparation |
| + | |} |
| | | |
− | $limit=10;
| + | <br> |
− | | |
− | // check for an empty string and display a message.
| |
− | if ($trimmed == "")
| |
− | {
| |
− | echo "<p>Please enter a search...</p>";
| |
− | // exit;
| |
− | }
| |
− | | |
− | // check for a search parameter
| |
− | if (!isset($var))
| |
− | {
| |
− | echo "<p>We dont seem to have a search parameter!</p>";
| |
− | // exit;
| |
− | }
| |
− | | |
− | $db="";
| |
− | | |
− | include("connect_db_ebiordb1.php");
| |
− | | |
− | | |
− | // Build SQL Query
| |
− | // $query = "select * from the_table where 1st_field like \"%$trimmed%\"
| |
− | // order by 1st_field"; // EDIT HERE and specify your table and field names for the SQL query
| |
− | | |
− | $query="SELECT Livre, MotCle, Resume, NbreChapSeg, NbreVersSeg, NbreChapCram, NbreVersCram FROM sophonie_livre WHERE (((sophonie_livre.NoLivIT)=0)) ORDER BY Livre";
| |
− | | |
− | $numresults=mysql_query($query,$db);
| |
− | $numrows=mysql_num_rows($numresults);
| |
− | | |
− | | |
− | if ($numrows == 0)
| |
− | {
| |
− | echo "<h4>Results</h4>";
| |
− | echo "<p>Sorry, your search returned zero results</p>";
| |
− | }
| |
− | | |
− | // next determine if s has been passed to script, if not use 0
| |
− | if (empty($s)) {
| |
− | $s=0;
| |
− | }
| |
− | | |
− | // get results
| |
− | $query .= " limit $s,$limit";
| |
− | $result = mysql_query($query,$db) or die("Couldn't execute query");
| |
− | | |
− | | |
− | echo "<TABLE BORDER=1>
| |
− | <CAPTION>Livre3Query</CAPTION><TR>";
| |
− | echo "<TH></TH>";
| |
− | echo "<TH>Livre</TH>";
| |
− | echo "<TH>MotCle</TH>";
| |
− | echo "<TH>Resume</TH>";
| |
− | echo "<TH>NbreChapSeg</TH>";
| |
− | echo "<TH>NbreVersSeg</TH>";
| |
− | echo "<TH>NbreChapCra</TH>";
| |
− | echo "<TH>NbreVersCra</TH></TR>";
| |
− | | |
− | // begin to show results set
| |
− | $count = 1 + $s ;
| |
− | | |
− | // now you can display the results returned
| |
− | while ($row= mysql_fetch_array($result)) {
| |
− | | |
− | $title1 = $row["Livre"];
| |
− | $title2 = $row["MotCle"];
| |
− | $title3 = $row["Resume"];
| |
− | $title4 = $row["NbreChapSeg"];
| |
− | $title5 = $row["NbreVersSeg"];
| |
− | $title6 = $row["NbreChapCram"];
| |
− | $title7 = $row["NbreVersCram"];
| |
− | | |
− | echo "<TR><TD>$count</TD><TD>$title1</TD><TD>$title2</TD><TD>$title3</TD><TD>$title4</TD><TD>$title5</TD><TD>$title6</TD><TD>$title7</TD></TR>" ;
| |
− | $count++ ;
| |
− | // $s++;
| |
− | }
| |
− | | |
− | $currPage = (($s/$limit) + 1);
| |
− | | |
− | //break before paging
| |
− | echo "</TABLE><br />";
| |
− | | |
− | // next we need to do the links to other results
| |
− | if ($s>=1) { // bypass PREV link if s is 0
| |
− | $prevs=($s-$limit);
| |
− | // print " <a href=\"$PHP_SELF?s=$prevs\"><<
| |
− | print " <a href=\"$PHP_SELF?s=$prevs&q=$var\"><<
| |
− | Prev 10</a>  ";
| |
− | }
| |
− | | |
− | // calculate number of pages needing links
| |
− | $pages=intval($numrows/$limit);
| |
− | | |
− | // $pages now contains int of pages needed unless there is a remainder from division
| |
− | | |
− | if ($numrows%$limit) {
| |
− | // has remainder so add one page
| |
− | $pages++;
| |
− | }
| |
− | | |
− | // check to see if last page
| |
− | if (!((($s+$limit)/$limit)==$pages) && $pages!=1) {
| |
− | | |
− | // not last page so give NEXT link
| |
− | $news=$s+$limit;
| |
− | | |
− | | |
− | echo " <a href=\"$PHP_SELF?s=$news&q=$var\">Next 10 >></a>";
| |
− | // echo " <a href=\"$PHP_SELF?s=$news\">Next 10 >></a>";
| |
− | }
| |
− | | |
− | $a = $s + ($limit) ;
| |
− | if ($a > $numrows) { $a = $numrows ; }
| |
− | $b = $s + 1 ;
| |
− | echo "<p>Showing results $b to $a of $numrows</p>";
| |
− |
| |
− | ?>
| |
− | </addhtm>
| |