Jump to content

Pagnation help?


darkfreaks

Recommended Posts

ok so the paging works perfect but it is onlyshowing one entry instead of 25 per page any thoughts?

 

 

<?php
$strTitle = "Bulletin Board";
define('QUADODO_IN_SYSTEM', true);
require_once('includes/header2.php');
$logname = stripslashes($qls->user_info['username']);

$catid = $qls->Security->make_safe($_GET['catid']);
$covid = $qls->Security->make_safe($_GET['covid']);

if (empty($logname)) {
echo "You MUST be logged in to view this page";
}else{


include ('config.php');
$query1=trim(mysql_real_escape_string($query1));
$query1 = "SELECT * FROM vc_coven WHERE id='$covid'";
$result1 = mysql_query($query1);

$num=mysql_num_rows($result1);

mysql_close();

$i=0;
while ($i < $num) {

$id = mysql_result($result1,$i,"id");
$header = mysql_result($result1,$i,"header");
$name = mysql_result($result1,$i,"name");

include ('config.php');
$query6=trim(mysql_real_escape_string($query6));
$query6 = "SELECT * FROM vc_covenmembers WHERE covenname='$name' AND username='$logname'";
$result6 = mysql_query($query6);

$num=mysql_num_rows($result6);

mysql_close();

$i=0;
for ($i = 0; $i < $num; $i++) {

$status = mysql_result($result6,$i,"status");

echo "<form method='post' action='delete.php'>
<input type='hidden' name='catid' value='$covid'>
$header
<a href='../covens/$name'><h2>$name</h2></a>";

include ('config.php');
$localhost = "mysql1.100ws.com";
$dbuser = "chrxtr2_dbase"; 
$dbpass = "l0v3sux";
$dbtable = "chrxtr2_dbase";

$site_url = "http://vampirecity.cx-music.com";

$conn = mysql_connect("$localhost","$dbuser","$dbpass")
or die("Error Could not connect");

mysql_select_db($dbtable);
$query3=trim(mysql_real_escape_string($query3));
$query3 = "SELECT * FROM vc_coventopics WHERE catid='$catid'";
$result3 = mysql_query($query3);

$numrows=mysql_num_rows($result3);




mysql_close();

$i=0;
while ($i < $num) {

$catid = mysql_result($result3,$i,"catid");
$username = mysql_result($result3,$i,"username");
$date = mysql_result($result3,$i,"date");
$message = mysql_result($result3,$i,"message");
$title = mysql_result($result3,$i,"title");

echo "<table width=\"60%\" cellpadding=\"0\" cellspacing=\"0\">
<tr valign='top'>
<td width=\"10%\" align=\"center\">
<a href=\"../profile/$username\"><br>$username</a><br>
</td>
<td width=\"50%\">
<table border=\"0\" width=\"100%\" class=\"titlebar\">
<tr><td align=\"left\"><B>$title</B></td><td align=\"right\">
$date
</td></tr>
</table>
$message
</td></tr>
</table>
";

$i++;
};

echo "<p>";

include ('config.php');

$result2 = "SELECT * FROM vc_covenmessages WHERE catid='$catid' ORDER BY `id` DESC";
$result2 = mysql_query($result2);
$total = mysql_num_rows($result2);
$perpage = (($_GET['ppage'] >= 1) and ($_GET['ppage'] < 50))?$_GET['ppage']:3; //Default records/page
$pages = ceil($total / $perpage);
$pageid = (($_GET['pageid'] >= 1) and ($_GET['pageid'] <= $pages))?$_GET['pageid']:1;
$from = ($pageid - 1) * $perpage;

$result4 = "SELECT * FROM vc_covenmessages WHERE catid='$catid' ORDER BY `id` DESC LIMIT $from,$perpage";
$numrows=mysql_num_rows($result4);
$result4 = mysql_query($result4);
while($rows = mysql_fetch_array($result4))
{

}
echo "\r\n";

$next = $pageid+1;
$previous = $pageid-1;
if ($pageid > 1) echo "<a href='board.php?catid=$catid&covid=$covid&pageid=$previous&ppage=$ppage'><< Previous</a>\r\n";
if ($pageid > 3) echo "...\r\n";
for ($i=(($pageid>2)?$pageid-2:1); $i<=(($pageid<($pages-2))?$pageid+2:$pages); $i++) {
  if($pageid == $i) echo "<b>$i</b>\r\n"; 
  else echo "<a href='board.php?catid=$catid&covid=$covid&pageid=$i&ppage=$perpage'>$i</a>\r\n";
}
if ($pageid < ($pages-2)) echo "...\r\n";
if ($pageid < $pages) echo "<a href='board.php?catid=$catid&covid=$covid&pageid=$next&ppage=$ppage'>Next >></a>\r\n";  

mysql_close();

$i=0;
while ($i < $num) {

$catid = mysql_result($result4,$i,"catid");
$id = mysql_result($result4,$i,"id");
$username = mysql_result($result4,$i,"username");
$date = mysql_result($result4,$i,"date");
$message = mysql_result($result4,$i,"message");
$title = mysql_result($result4,$i,"title");

echo "<table width=\"60%\" cellpadding=\"0\" cellspacing=\"0\" class=\"cmessage\">
<tr valign='top'>
<td width=\"10%\" align=\"center\">
<a href=\"../profile/$username\"><br>$username</a><br>";
if ($status=="owner") {
echo "<input type='checkbox' name='id' value='$id'>";
};
if ($status=="admin") {
echo "<input type='checkbox' name='id' value='$id'>";
};
echo "</td>
<td width=\"50%\">
<table border=\"0\" width=\"100%\" class=\"titlebar\">
<tr><td align=\"left\"><B>$title</B></td><td align=\"right\">
$date
</td></tr>
</table>
$message
</td></tr>
</table>
";

$i++;
};

if ($status=="owner") {
echo "<input type='submit' name='deletemessage' value='Delete Message'>";
};
if ($status=="admin") {
echo "<input type='submit' name='deletemessage' value='Delete Message'>";
};
echo "</form>";
?>
<p>
<form name="sendmessage" id="sendmessage" method="post" action="messageleft.php">
<input type="hidden" name="date" id="date" value="<?php
$date_time = date('l M d, Y g:i A');
echo ($date_time); 
?>(GMT)">
<input type="hidden" name="username" value="<?php echo $logname; ?>"><br>
<input type="hidden" name="catid" value="<?php echo $catid; ?>"><br>
<input type="hidden" name="covid" value="<?php echo $covid; ?>"><br>
<br>
Title <input type="text" name="title" id="title" value="<?php echo $title; ?>"><br>
<textarea rows="10" cols="60" name="message" id="message"></textarea>
<br>
<input type="submit" id="submit" name="submit" value=" Send Message ">
</form>
<?php
$i++;
};
};
};
include ('includes/footer.php');
?>

Link to comment
Share on other sites

I dont know if this will help but this is what im using it displays 5 records accross the top of the page I just can't get it to start another row

<?php

include("sharons_dbinfo.inc.php");
mysql_connect(mysql,$username,$password);
mysql_select_db(mydatabase) or die( "Unable to select database");

//Count rows
$query = "SELECT count(*) FROM content";
$result = mysql_query($query) or trigger_error("SQL", E_USER_ERROR);
$query_data = mysql_fetch_row($result);
$numrows = $query_data[0];

$page = ( isset( $_GET['page'] ) && is_numeric( $_GET['page'] ) ) ? $_GET['page'] : 1;

$query = "SELECT count(*) FROM `content`";
$result = mysql_query( $query );
$fetch = mysql_fetch_row( $result );
$numRows = $fetch[0];

$rowsPerPage = ( isset( $_GET['show'] ) && is_numeric( $_GET['show'] && $_GET['show'] >= 1 ) && $_GET['show'] <= 40 ) ? $_GET['show'] : 5;
$lastPage = ceil( $numRows / $rowsPerPage );

$page = (int)$page;
if( $page < 1 )
{
   $page = 1;
}
elseif( $page > $lastPage )
{
   $page = $lastPage;
}

if( $numRows > 0 ) $limit = 'LIMIT ' . ( $page - 1 ) * $rowsPerPage . ',' . $rowsPerPage;
else $limit = '';

//Query the DB
$query = "SELECT * FROM content $limit";
$result = mysql_query($query) or trigger_error("SQL", E_USER_ERROR);


// PROCESS CONTENTS OF $RESULTS

print "<table width='0' align='center'><tr>";
while ($info = mysql_fetch_array($result)) {
print "<td width='0' ALIGN='CENTER'>";
echo $info['heading'];
echo "<BR>";
echo $info['picture'];
echo "<BR>";
echo $info['description'];
echo"<BR></td>";
}
echo"</tr>";
$lastPage = (int)$lastPage;

if ( $page == 1 )
{
echo( 'FIRST PREVIOUS' );
}
else
{
$prevPage = $page - 1;
echo( '<a href="?page=1" class="first">FIRST</a><a href="?page=' . $prevPage . '">PREV</a>' );    
}

$totalPages = $lastPage;
$curentPage = $page;
if ( $totalPages < 8 )
{
$start = 1;
$end = $totalPages;
}
else
{
if ( $curentPage > 3 )
{
	if ( $totalPages - $curentPage < 3 ) $end = $totalPages;
	else $end = $curentPage + 3;
	$start = $end - 6;
}
else
{
	$start = 1;
	$end = 7;
}
}

echo( '<strong>Page:</strong> ' );

if ( $start > 1 ) echo ' ... ';
for ( $i = $start; $i <= $end; $i++ )
{
if ( $i == $curentPage ) echo( '<span style="font-weight:bold;">' . $i . '</span>' ); else echo ' <a href="?id=' . $_GET['id'] . '&page=' . $i . '" style="font-size:1.00em;">' . $i . '</a> ';
}
if ( $end < $totalPages ) echo ' ... ';
echo( "<strong> of {$totalPages}</strong>" );

if ($page == $lastPage)
{
echo( 'NEXT LAST');
}
else
{
$nextPage = $page + 1;
?>
    <a href="?page=<?php echo $nextPage; ?>">NEXT</a>
<a href="?page=<?php echo $lastPage; ?>">LAST</a>
<?php
}
?>

Link to comment
Share on other sites

Im just guessing here because I don't know that much about it but try this

Change this

$result2 = "SELECT * FROM vc_covenmessages WHERE catid='$catid' ORDER BY `id` DESC";
$result2 = mysql_query($result2);
$total = mysql_num_rows($result2);
$perpage = (($_GET['ppage'] >= 1) and ($_GET['ppage'] < 50))?$_GET['ppage']:3; //Default records/page
$pages = ceil($total / $perpage);
$pageid = (($_GET['pageid'] >= 1) and ($_GET['pageid'] <= $pages))?$_GET['pageid']:1;
$from = ($pageid - 1) * $perpage;

To This

$result2 = "SELECT * FROM vc_covenmessages WHERE catid='$catid' ORDER BY `id` DESC";
$result2 = mysql_query($result2);
$total = mysql_num_rows($result2);
$perpage = (($_GET['ppage'] >= 1) and ($_GET['ppage'] < 50))?$_GET['ppage']:3; //Default records/page
$pages = ceil($total / $perpage);
$pageid = (($_GET['pageid'] >= 1) and ($_GET['pageid'] <= $pages))?$_GET['pageid']:25;
$from = ($pageid - 1) * $perpage;

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.