Différences entre versions de « DB Ebior2 »
m (A protégé « DB Ebior2 » ([edit=sysop] (infini) [move=sysop] (infini))) |
m (A déprotégé « DB Ebior2 ») |
(Aucune différence)
|
Version du 24 juin 2010 à 12:24
'Test du PHPoutput2
<addhtml>
<?php
// Get the search variable from URL $var = @$_GET['q'] ; $s = @$_GET['s'] ;
$trimmed = trim($var); //trim whitespace from the stored variable
// rows to return
$limit=10;
// check for an empty string and display a message.
if ($trimmed == "") {
echo "
Please enter a search...
";
// exit;
}
// check for a search parameter
if (!isset($var)) {
echo "
We dont seem to have a search parameter!
";
// 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 "
Results
"; echo "
Sorry, your search returned zero results
";
}
// 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 "
"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "";// 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 "" ;
$count++ ;
// $s++;
}
$currPage = (($s/$limit) + 1);
//break before paging
echo "Livre | MotCle | Resume | NbreChapSeg | NbreVersSeg | NbreChapCra | NbreVersCra | |
---|---|---|---|---|---|---|---|
$count | $title1 | $title2 | $title3 | $title4 | $title5 | $title6 | $title7 |
";
// 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 "
Showing results $b to $a of $numrows
";
?> </addhtm>