Jump to content

Need help lease


richarro1234

Recommended Posts

Hey all,

im having some problems with this code.

basically i would like to set-up pagination for it as it is often updated and gets big pretty quick,

all the sctipts i havelooked at dont seem to work i was wondering if someone could help me with the pagination please

 

Thanks in advance

Rich

 

<?include("header.php");?>
<?
if ($_COOKIE["status"] == "online") {
include("data.php");
mysql_connect($server,$username, $password);
mysql_select_db($database);
$query = mysql_query("SELECT * from users WHERE username = '".$_COOKIE["twusername"]."'");
while ($r = mysql_fetch_array($query)) {
?>
<center>
<?=$note?></center>
<br>
<? 
if ($r['username'] == 'richarro123') {
?>
<div align="center">
  <center>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#5D6765" width="95%" id="AutoNumber1" bgcolor="#131313">
  <tr>
    <td width="17%" align="center" bgcolor="#000000"><b>Admin</b></td>
    <td width="17%" align="center" bgcolor="#000000"><b>User Edited</b></td>
    <td width="17%" align="center" bgcolor="#000000"><b>Value Edited</b></td>
    <td width="17%" align="center" bgcolor="#000000"><b>Original Value</b></td>
    <td width="16%" align="center" bgcolor="#000000"><b>New Value</b></td>
    <td width="16%" align="center" bgcolor="#000000"><b>Date</b></td>
  </tr>
  <tr>
    <td width="100%" align="center" colspan="6"> </td>
  </tr>
<?php
$results= mysql_query("SELECT * FROM adminactionlog Order by date desc"); 
$id = "id";
$adminname = "adminname";
$username = "username";
$action = "action";
$origvalue = "origvalue";
$newvalue = "newvalue";
$date = "date";
echo mysql_error();

if (mysql_Numrows($results)>0)                            //if there are records in the fields
{ 
  $numrows=mysql_NumRows($results);                       //count them
  $x=0; 
  while ($x<$numrows){   //loop through the records
    
    $theid=mysql_result($results,$x,$id);
    $theadminname=mysql_result($results,$x,$adminname);
    $theusername=mysql_result($results,$x,$username);
    $theaction=mysql_result($results,$x,$action);
    $theorigvalue=mysql_result($results,$x,$origvalue);
    $thenewvalue=mysql_result($results,$x,$newvalue);
    $thedate=mysql_result($results,$x,$date);

$logdate = date("m/d/Y h:i a",$thedate);

?>
<?
$query = mysql_query("SELECT * from users WHERE username = '$theadminname'");
while ($adminlink = mysql_fetch_array($query)) {
?>
<?
$query = mysql_query("SELECT * from users WHERE username = '$theusername'");
while ($memlink = mysql_fetch_array($query)) {
?>
  <tr>
    <td width="17%" align="center"><a href="profile.php?id=<?=$adminlink['id'];?>"><?=$theadminname?></a> </td>
    <td width="17%" align="center"><a href="profile.php?id=<?=$memlink['id'];?>"><?=$theusername?></a> </td>
    <td width="17%" align="center"><?=$theaction?> </td>
    <td width="17%" align="center"><?=$theorigvalue?> </td>
    <td width="16%" align="center"><?=$thenewvalue?> </td>
    <td width="16%" align="center"><?=$logdate?> </td>
  </tr>
<?
    $x++;
  }
?>
<?}?>
<?}?>
<?}?>
</table>
  </center>
</div>
<?} else {?>
<center><b>!</b></center>
<?}?>
<br>
<?
}
} else {
require( 'notloggedin.php' );
}?>
<?include("footer.php");?>

Link to comment
Share on other sites

<?php 
if(isset($submit)) {

  $page = $_GET["page"];
  $rowmax = 10; //Set this to the number of items you want returned per page

     if(!isset($page)) {
      $page = 1;
   }
   
    if($page == 1) {       
       $pagein = 0;
    }   
    
   if($page > 1) { 
      $pagein = $page * $rowmax - $rowmax;
   }
include("data.php");
mysql_connect($server,$anvandare, $losen);
mysql_select_db($databas);
//Below is where the total number of rows will be calculated

//Below is where you would do the selected query to draw only paginated results.
$results= mysql_query("SELECT * FROM adminactionlog Order by date desc LIMIT $pagein, $rowmax"); 
$id = "id";
$adminname = "adminname";
$username = "username";
$action = "action";
$origvalue = "origvalue";
$newvalue = "newvalue";
$date = "date";
echo mysql_error();

if (mysql_Numrows($results)>0)                            //if there are records in the fields
{ 
  $numrows=mysql_NumRows($results);                       //count them
  $x=0; 
  while ($x<$numrows){   //loop through the records
    
    $theid=mysql_result($results,$x,$id);
    $theadminname=mysql_result($results,$x,$adminname);
    $theusername=mysql_result($results,$x,$username);
    $theaction=mysql_result($results,$x,$action);
    $theorigvalue=mysql_result($results,$x,$origvalue);
    $thenewvalue=mysql_result($results,$x,$newvalue);
    $thedate=mysql_result($results,$x,$date);

$logdate = date("m/d/Y h:i a",$thedate);

?>
<?
$query = mysql_query("SELECT * from users WHERE username = '$theadminname'");
while ($adminlink = mysql_fetch_array($query)) {
?>
<?
$query = mysql_query("SELECT * from users WHERE username = '$theusername'");
while ($memlink = mysql_fetch_array($query)) {
?>
  <tr>
    <td width="17%" align="center"><a href="profile.php?id=<?=$adminlink['id'];?>"><?=$theadminname?></a> </td>
    <td width="17%" align="center"><a href="profile.php?id=<?=$memlink['id'];?>"><?=$theusername?></a> </td>
    <td width="17%" align="center"><?=$theaction?> </td>
    <td width="17%" align="center"><?=$theorigvalue?> </td>
    <td width="16%" align="center"><?=$thenewvalue?> </td>
    <td width="16%" align="center"><?=$logdate?> </td>
  </tr>
<?
    $x++;
  }
?>
<?}?>
<?}?>
<?}    
$result1 = mysql_query($query1);

while($row = mysql_fetch_array($result1)){
//This is the area where the paginated ruslts will be displayed by row results
}

//Below will only do calutaions if query was successful
if($result1 != null) {
$pagecount = ceil($num_rows / $rowmax);
$resultinput = $pagein + 1;
$resultsoutput = $pagein + $rowmax;
if($resultsoutput > $num_rows) {$resultsoutput = $num_rows;}//Change $resultsoutput to $num_rows on last page here

//Only displays pagination links if necessary below here
if ($pagecount > 1) {
     echo "Page ";
     $x = 1;
     $y = $pagecount;
        for( $i = $x; $i <= $y; $i++ ) {
     print "<a href='adminlog1.php?page=$i'><b>[$i]</b></a> ";
        }
         
   }
echo "<p align='center'>There were $num_rows results.<br />//Shows the total number of resutls on this line
      You are viewing results $resultinput through $resultsoutput.</p>";//shows which results you are viewing here
  }
}
?>

 

Thats what i got and all it shows is a blank white page.

Link to comment
Share on other sites

Blank page is a good indication you have errors in your code.

 

Enable error reporting and display errors to see if what it returns.

 

Also, why do you stop and start PHP back to back so often?  You may also want to substitute full <?php tags instead of <? short tags.

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.