View Single Post
Old 01-07-2007, 12:44 PM   #5 (permalink)
markster
Code Monkey
 
markster's Avatar
 
Join Date: Jun 2006
Posts: 65
markster is on a distinguished road
Thanks!

Thanks sooo much! I've sorted out your mistakes, edited it down into one script, and updated it to include 15 results per page. I've posted it below incase another user might find it useful.

PHP Code:
<?php
    
require_once("mysql_connect.php");
    
$result mysql_query("SELECT count(*) FROM jokes WHERE cat=$cat");
    
$count mysql_result($result,0,0);
    
$number_of_groups ceil($count/15);
    
$starting_group_number 1;
    for (
$i=1;$i<=$number_of_groups;$i++) {
      
$second_num $starting_group_number+14;
      echo(
"<a href=\"jokes.php?star=$starting_group_number&cat=$cat\">$starting_group_number - $second_num</a>&nbsp; &nbsp;\n");
      
$starting_group_number += 15;
    }    
    echo(
"<br><br>");
    if (!
$_GET['start']) {
      
$start 1;
    } else {
      
$start $_GET['start'];
    }
    
$begnum $start 1;
    
$query2 "SELECT id, title, author FROM jokes WHERE cat=$cat LIMIT $begnum, 15";
    
$result2 mysql_query($query2);
    echo(
"<table width=\"80%\" border=\"0px\">\n");
    echo(
"<tr><td width=\"80%\"><b>Title<b></td><td width=\"20%\"><b>Written By</b></td></tr>");
    while (
$row mysql_fetch_array($result2MYSQL_ASSOC)) {
        
$id $row['id'];
        
$title $row['title'];
        
$author $row['author'];
        echo(
"<tr><td><a href=\"joke.php?id=$id\">$title</a></td><td><a href=\"user.php?user=$author\">$author</a></td></tr>");
    }
    echo(
"</table>");
    
?>
markster is offline   Reply With Quote