Jump to content

Help with page number. Where am I going wrong?


mrdobalina

Recommended Posts

<?php

$con=mysqli_connect("address","username","pass","db name");
// Check connection
if (mysqli_connect_errno()) {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

if (!(isset($pagenum))) 
{ 
 $pagenum = 1; 
 }

$data = mysqli_query($con,"SELECT * FROM info");

$rows = mysql_num_rows($data);

$page_rows = 15;

$last = ceil($rows/$page_rows);

if($pagenum < 1);
{ 

 $pagenum = 1;
 
 } 
 elseif ($pagenum > $last); 
 {
$pagenum = $last; 
 } 
$max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows; 
 
$result = mysql_query($con,"SELECT * FROM topsites $max") or die(mysql_error()); 
 
 
echo "<table border='1' class='boldtable' cellpadding='2'>
<tr>
<th>Creditor</th>
<th>dd/mm/yyyy</th>
<th>Credit Score</th>
<th>State</th>

<th>Income</th>

<th>Approval</th>
<th>Credit Line</th>
<th>Interest</th>
<th>Comment</th>
</tr>";

while($row = mysqli_fetch_array($result)) {
  echo "<tr>";
  echo "<td>" . $row['creditor'] . "</td>";
  echo "<td>" . $row['date'] . "</td>";	 
  echo "<td>" . $row['fako'] . "</td>";
  echo "<td>" . $row['state'] . "</td>";

  echo "<td>" . $row['income'] . "</td>";

  echo "<td>" . $row['approval'] . "</td>";
  echo "<td>" . $row['creditline'] . "</td>";
  echo "<td>" . $row['interest'] . "</td>";
  echo "<td>" . $row['comments'] . "</td>";
  echo "</tr>";
}

echo "</table>";

echo " --Page $pagenum of $last-- <p>";
if ($pagenum == 1)

{

} 
 
 else
 
{

echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=1'> <<-First</a> ";

echo " ";

$previous = $pagenum-1;

echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$previous'> <-Previous</a> ";

}

echo " ---- ";

if ($pagenum == $last)

{

}

else {

$next = $pagenum+1;

echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$next'>Next -></a> ";

echo " ";

echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$last'>Last ->></a> ";

}

mysqli_close($con);

?>

All I want are the pages broken up into pages. It is going wrong somewhere before my table. Can someone help me out? Thank you!

Link to comment
Share on other sites

It is going wrong somewhere before my table.

 

 

in addition to what has already been mentioned, your code contains both the mysqli_ and mysql_ (no i) database functions (these cannot be mixed together on one database connection), so of course the code using the mysql_ (no i) functions is not working. you need to use all mysqli_ functions.

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.