Don't like ads? PRO users don't see any ads ;-)

edit

By: CBDC on May 6th, 2012  |  syntax: PHP  |  size: 2.49 KB  |  hits: 18  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.  
  2.  
  3.  
  4. <?php
  5.  
  6.  
  7.         session_start ();
  8.                
  9.         if ( ! isset ( $_SESSION [ 'email' ] ) )
  10.         {
  11.                
  12.                         echo "<center> <p style=\"font-family:Tahoma; font-size:40;\">Access denied !";
  13.                                                
  14.                         header ( "Refresh: 3 url=main.php" );
  15.                                                
  16.                         exit;
  17.                                
  18.         }
  19.         else
  20.         {
  21.                
  22.                
  23.                         include ("links.php");
  24.  
  25.                         echo "<center><h2>Click on an ID# to edit.</center></h2>";
  26.                
  27.                         mysql_connect ( "localhost", "root" , "" )or die ( "Something went wrong !" );
  28.                
  29.                         mysql_select_db ( "data1" );
  30.                
  31.                         $per_page = 4;
  32.                         $pages_query = mysql_query ( "SELECT COUNT( 'id' )      FROM users" );
  33.                         $pages = ceil ( mysql_result ( $pages_query, 0 ) / $per_page );
  34.                         $page = (  isset ( $_GET [ 'page' ] ) ) ?( int ) $_GET [ 'page' ]: 1;
  35.                         $start = ( $page - 1 )  *       $per_page;
  36.                         $query = mysql_query ( "SELECT * FROM users     LIMIT  $start, $per_page" );
  37.                
  38.                
  39.                         echo
  40.                         "
  41.                                 <table width=\"60%\" align=center border=1>
  42.                                 <tr>
  43.                                 <td width=\"40%\" align=center bgcolor=\"FFFF00\">
  44.                                         ID
  45.                                 </td>
  46.                                                
  47.                                 <td width=\"40%\" align=center bgcolor=\"FFFF00\">
  48.                                         Name
  49.                                 </td>
  50.                                                                
  51.                                 <td width=\"40%\" align=center bgcolor=\"FFFF00\">
  52.                                         Email
  53.                                 </td>
  54.                                                                                
  55.                                 <td width=\"40%\" align=center bgcolor=\"FFFF00\">
  56.                                         Password
  57.                                 </td>
  58.                                 </tr>
  59.                         ";
  60.                                        
  61.         while ( $row = mysql_fetch_assoc ( $query) )
  62.         {
  63.                                
  64.                 $id = $row [ 'id' ];
  65.                 $name = $row [ 'name' ];
  66.                 $email = $row [ 'email' ];
  67.                 $password = $row  [ 'password' ];
  68.                                                
  69.                 echo
  70.                 "
  71.                         <tr>
  72.                         <td align=center>
  73.                                                                                                                 <a href=\"update.php?ids=$id&names=$name&emails=$email&passwords=$password\">$id</a>
  74.  
  75.                         </td>
  76.                         <td>$name</td>
  77.                         <td><a href=\"mailto.php?emails=$email\">$email</td>
  78.                         <td>$password</td>
  79.                         </tr>
  80.                 ";
  81.                                
  82.         }
  83.                                
  84.                 echo "</table>";
  85.                                
  86.                 $prev = $page - 1;
  87.                 $next = $page + 1;
  88.                                
  89.                 echo "<center>";
  90.                                
  91.                 if ( ! ( $page <=1 ) )
  92.                 {
  93.                                                
  94.                         echo "<a href='edit.php?page=$prev' style=\"text-decoration:none;\"</a>< "."&nbsp&nbsp&nbsp";
  95.                                                
  96.                 }
  97.  
  98.                         if ( $pages >= 1)
  99.                         {
  100.                                
  101.                                 for ( $x = 1; $x <= $pages; $x++ )
  102.                                                
  103.                                                
  104.                                 echo ( $x == $page ) ? '<b><a href="?page='.$x.'">'.$x.'</a></b>&nbsp&nbsp'     : '<a href="?page='.$x.'">'.$x.'</a>&nbsp&nbsp';
  105.  
  106.                                
  107.                         }
  108.                                
  109.                                 if ( ! ( $page >= $pages ) )
  110.                                 {
  111.                                                
  112.                                         echo "<a href='edit.php?page=$next' style=\"text-decoration:none;\"</a>&nbsp&nbsp&nbsp>";
  113.                                                                
  114.                                 }
  115.                                                
  116.                 echo "</center>";
  117.                                
  118.                 mysql_close ();
  119.                                
  120.         }
  121.                
  122.                
  123.                
  124.                
  125.                
  126.                
  127.                
  128.                
  129.                
  130.                
  131.                
  132.                
  133.                
  134.                
  135.                
  136.                
  137. ?>