"; //echo "Sorting by = $sortby (blank = default)
"; //echo "v calculations v
"; //first 10 //SELECT * //FROM tbt_poetry //WHERE `category` =22 //ORDER BY `tbt_poetry`.`timestamp` DESC //LIMIT 0 , 10 //SELECT * //FROM tbt_poetry //WHERE `category` =22 ///ORDER BY `tbt_poetry`.`timestamp` DESC // //LIMIT 10 , 10 //echo "(DEBUG STUFF: This query should show page $page of the $category category sorted by $sortby ($ascdesc))
"; if (isset($category)) { include("$opendatabase"); $query = "SELECT * FROM tbt_categories WHERE `category`='$category'"; $result = mysql_query($query) or die("Couldn't submit query (checking if cat exists): ".mysql_error()); $num = mysql_num_rows($result); if ($num == 1) { $cat = mysql_result($result,0,"cat"); $startfrom = ($page - 1) * $limit; //echo "$category (unique id: $cat) exists and the query will continue........"; include("$opendatabase"); $query2 = "SELECT `tbt_poetry`.`p`, `tbt_poetry`.`foreword`, `tbt_poetry`.`id`, `tbt_poetry`.`date`, `tbt_poetry`.`title`, `tbt_poetry`.`timestamp`, `tbt_members`.`user` FROM tbt_poetry, tbt_members WHERE (`tbt_members`.`id`=`tbt_poetry`.`id`) AND `tbt_poetry`.`category`='$cat' LIMIT $startfrom,$limit"; $query3 = "SELECT `tbt_poetry`.`p` FROM tbt_poetry, tbt_members WHERE (`tbt_members`.`id`=`tbt_poetry`.`id`) AND `tbt_poetry`.`category`='$cat'"; $result2 = mysql_query($query2) or die("Couldn't submit query (pulling poetry): ".mysql_error()); $num2 = mysql_num_rows($result2); $result3 = mysql_query($query3) or die("Couldn't submit query (pulling poetry): ".mysql_error()); $num3 = mysql_num_rows($result3); echo "Showing $num2 poems of $num3 results.
"; echo "
echo $title; ?> by echo $user; ?> echo $timestamp; ?> |
echo $foreword; ?> |
} $append = ""; // if (isset($sortby) AND $sortby != NULL OR isset($ascdesc) AND $ascdesc != NULL) // { $append = "?"; } // if (isset($sortby) AND $sortby != NULL) { $append = $append . "sortby=$sortby"; $appended = TRUE; } // if ($appended == TRUE) { $append = $append . "&"; } // if (isset($ascdesc) AND $ascdesc != NULL) { $append = $append . "ascdesc=$ascdesc"; } $pages = $num3 / $limit; $prev = $page - 1; if ($prev > 0){ $prevurl = "/c/Uncategorised/$prev/"; } else { $prevurl = "#"; } $next = $page + 1; if ($next < $pages){ $nexturl = "/c/Uncategorised/$next/"; } else {$nexturl = "#"; } echo "< Previous Page"; echo " - "; echo "Next Page >
"; for ($i3 = 1; $i3 < $pages; $i3++) { if ($i3 == $page) { echo "$i3 "; } else { echo "$i3 "; } if ($i3 == 20 OR $i3 == 40 or $i3 == 60) { echo "
"; } } echo "