
edit
By:
CBDC on
May 6th, 2012 | syntax:
PHP | size: 2.49 KB | hits: 18 | expires: Never
<?php
session_start ();
if ( ! isset ( $_SESSION [ 'email' ] ) )
{
echo "<center> <p style=\"font-family:Tahoma; font-size:40;\">Access denied !";
header ( "Refresh: 3 url=main.php" );
exit;
}
else
{
include ("links.php");
echo "<center><h2>Click on an ID# to edit.</center></h2>";
mysql_connect ( "localhost", "root" , "" )or die ( "Something went wrong !" );
mysql_select_db ( "data1" );
$per_page = 4;
$pages_query = mysql_query ( "SELECT COUNT( 'id' ) FROM users" );
$pages = ceil ( mysql_result ( $pages_query, 0 ) / $per_page );
$page = ( isset ( $_GET [ 'page' ] ) ) ?( int ) $_GET [ 'page' ]: 1;
$start = ( $page - 1 ) * $per_page;
$query = mysql_query ( "SELECT * FROM users LIMIT $start, $per_page" );
echo
"
<table width=\"60%\" align=center border=1>
<tr>
<td width=\"40%\" align=center bgcolor=\"FFFF00\">
ID
</td>
<td width=\"40%\" align=center bgcolor=\"FFFF00\">
Name
</td>
<td width=\"40%\" align=center bgcolor=\"FFFF00\">
Email
</td>
<td width=\"40%\" align=center bgcolor=\"FFFF00\">
Password
</td>
</tr>
";
while ( $row = mysql_fetch_assoc ( $query) )
{
$id = $row [ 'id' ];
$name = $row [ 'name' ];
$email = $row [ 'email' ];
$password = $row [ 'password' ];
echo
"
<tr>
<td align=center>
<a href=\"update.php?ids=$id&names=$name&emails=$email&passwords=$password\">$id</a>
</td>
<td>$name</td>
<td><a href=\"mailto.php?emails=$email\">$email</td>
<td>$password</td>
</tr>
";
}
echo "</table>";
$prev = $page - 1;
$next = $page + 1;
echo "<center>";
if ( ! ( $page <=1 ) )
{
echo "<a href='edit.php?page=$prev' style=\"text-decoration:none;\"</a>< "."   ";
}
if ( $pages >= 1)
{
for ( $x = 1; $x <= $pages; $x++ )
echo ( $x == $page ) ? '<b><a href="?page='.$x.'">'.$x.'</a></b>  ' : '<a href="?page='.$x.'">'.$x.'</a>  ';
}
if ( ! ( $page >= $pages ) )
{
echo "<a href='edit.php?page=$next' style=\"text-decoration:none;\"</a>   >";
}
echo "</center>";
mysql_close ();
}
?>