okay heres my new code and the button to actually link you to the letter works but it doesnt sort them. It does however number paginate the database:
<?php
$alphabet = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z');
foreach ($alphabet as $letter) {
echo "<a href=\"?letter=" . $letter . "\">" . $letter . "</a> ¦ ";
}
echo "<a href=\"?\">Show All</a></p><br />
<form method=\"POST\" action=\"?\">
<input type=\"text\" name=\"search\" /> <select name=\"categlory_eng\">
<option>Select Category</option>
<option value=\"\">All</option>
<option value=\"crack\">Crack</option>
<option value=\"serial\">Serials</option>
<option value=\"warze\">Warze</option>
</select>
<input type=\"submit\" name=\"submit\" value=\"search\" class=\"submit\" />
</form>";
?>
<!--mysql-->
<?php
if(empty($_POST)) {
$letter = $_POST['letter'];
$letter .= "%";
$search = $letter;
$sdesc = "*";
$classquery = "";
} else {
$search = $_post['search'];
$search = "%" . $search . "%";
$sdesc = "%" . $search . "%";
$sclass = $_POST['category_eng'];
$classquery = "AND 'category_eng' = CONVERT( _utf8 '" . $sclass . "' USING latin1 )";
}
mysql_connect("localhost", "root", "***PASSWORD***");
mysql_select_db("pages");
// If current page number, use it
// if not, set one!
if(!isset($_GET['page'])){
$page = 1;
} else {
$page = $_GET['page'];
}
// Define the number of results per page
$max_results = 5;
// Figure out the limit for the query based
// on the current page number.
$from = (($page * $max_results) - $max_results);
// Perform mysql query on only the current page number's results
$result = mysql_query("SELECT * FROM products ORDER BY name DESC LIMIT $from, $max_results")
or die(mysql_error());
//TO PRINT OUT THE DATA
echo "<table border='1'>";
echo "<tr> <th>ID</th> <th>Name</th> <th>List Type</th>";
// keeps getting the next row until there are no more to get
while($products = mysql_fetch_array( $result )) {
// Print out the contents of each row into a table
$link = $products['link'];
echo "<tr><td>";
echo $products['ID'];
echo "</td><td><a href='$link'>";
echo $products['Name'];
echo "<a></td><td>";
echo $products['type'];
echo "</td></tr>";
}
echo "</table>";
//STOP PRINTING OUT THE DATA
// Figure out the total number of results in DB:
$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM products ORDER BY name DESC"),0);
// Figure out the total number of pages. Always round up using ceil()
$total_pages = ceil($total_results / $max_results);
// Build Page Number Hyperlinks
echo "<p class=\"center\">Pages: ";
// Build Previous Link
if($page > 1){
$prev = ($page - 1);
echo "<a href=\"".$_SERVER['php_SELF']."?page=$prev\">«</a> ";
}
for($i = 1; $i <= $total_pages; $i++){
if(($page) == $i){
echo "$i ";
} else {
echo "<a href=\"".$_SERVER['php_SELF']."?page=$i &letter=$letter\">$i</a> ";
}
}
// Build Next Link
if($page < $total_pages){
$next = ($page + 1);
echo "<a href=\"".$_SERVER['php_SELF']."?page=$next\">»</a>";
}
echo "</p>";
mysql_close();
?>
can someone help make it "alphabetize"