Location: PHPKode > projects > The Easy Dictionary Maker > show_letter.php
<?php

/*====================================================================================================
======================================================================================================
The Dictionary Maker (TDM) is released under the GNU General Public License (GPL), which is an 
	open-source license that means anyone is free to use, modify, and 
	redistribute it, with a few restrictions. That means that the following 
	text should be included as a comment at the top of every source file:

	========================================================================
	Copyright Daniel Herman 2002

	This file is part of TDM.

	TDM is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 2 of the License, or
	(at your option) any later version.
	
	TDM is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with Beehive; if not, write to the Free Software
	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  
	USA
	========================================================================
============================================================================================*/

require("./header.php");

if(!$max_results_chosen){
$max_results_chosen = $max_results;
}

if(!$page){
$page = "1";
}

$page_lit = $page;

$a = "0";
$b = $max_results_chosen;
$c = "-$max_results_chosen";
$page = $a*($page^2)+($b*$page)+$c;

//---Define the top of the table before we go looping.

echo "<TABLE align=center><tr><TD>";

// Define the search query, along with the limit & where to begine from

$search_p = "$letter%";


switch($letter){

default:

$query = "SELECT * FROM $table_name WHERE word LIKE ('$search_p') ORDER BY word LIMIT $page,$max_results_chosen";

break;

case Other:

$query = "SELECT * FROM dict WHERE word NOT LIKE 'A%' AND word NOT LIKE 'B%' AND word NOT LIKE 'C%' AND word NOT LIKE 'D%' AND word NOT LIKE 'E%' AND word NOT LIKE 'F%' AND word NOT LIKE 'g%' AND word NOT LIKE 'h%' AND word NOT LIKE 'i%' AND word NOT LIKE 'j%' AND word NOT LIKE 'k%' AND word NOT LIKE 'l%' AND word NOT LIKE 'm%' AND word NOT LIKE 'n%' AND word NOT LIKE 'o%' AND word NOT LIKE 'p%' AND word NOT LIKE 'q%' AND word NOT LIKE 'r%' AND word NOT LIKE 's%' AND word NOT LIKE 't%' AND word NOT LIKE 'u%' AND word NOT LIKE 'v%' AND word NOT LIKE 'w%' AND word NOT LIKE 'x%' AND word NOT LIKE 'y%' AND word NOT LIKE 'z%'";

break;

}
echo "<center>";
// Perform the query and begins the loop to list the tables.

$result = mysql_query($query, $db) or die(mysql_error());
$numRows = mysql_num_rows($result);

// Define another numRows for future use

$numRowsOld = $numRows;

for ($count = 0; $count < $numRows; $count++) {
  $resultArray = mysql_fetch_array($result);
echo "<center>";
echo "<font face=$style_font_face color=$colour_font><a href=\"./show_word.php?did=";
echo $resultArray["did"];
echo "\">";
echo $resultArray["word"];
echo "</a><br>";

}


//------Lists all the pages----------
//----Query to find the number of results in total

$query = "SELECT * FROM $table_name WHERE word LIKE ('$search_p')";
$result = mysql_query($query, $db) or die(mysql_error());
$numRows = mysql_num_rows($result);

//------Work out how many pages there are etc.


$num_pages = $numRows / $max_results_chosen ;

$num_pages = ceil($num_pages);

$next_page = "";

//------If there is more than one page, list them all. Otherwise there is no point.

if($num_pages <= 1){
$num_pages = "";
$spacer = "";
}else{
$spacer = "<font face=\"Verdana\" size=\"1\" color=\"#0000000\">| ";
for ($link = 1; $link <= $num_pages; $link++) {

$next_page .= "<font face=$style_font_face color=$colour_font><a href=\"./show_letter.php?letter=$letter&page=$link\">$link</a></font> | ";

}
$results_show = $page+$numRowsOld;
$next_page .= "<BR><font face=$style_font_face color=$colour_font>Showing results $page to $results_show of $numRows results.";
}
echo $spacer;
echo $next_page;

require("./footer.php");
?>

Return current item: The Easy Dictionary Maker