build a paging system to this script

From: Design (design_at_aigel.com.pl)
Date: 09/27/04


Date: Mon, 27 Sep 2004 22:45:13 +0200

This is a nice working scrips for admin area of a logging system (php/mysql)
I want to build in a paging system, that could limit the number od users
displayed on one page to about 30, than displaying
links to next pages in further parts of data.
Can anyone help me in this matter, I'm not really good at php (the script
itself in downloaded from the web).
Here is the script (2 files):

(((config.php)))

<?php

$user_hostname = "mysqls.hostname";
$user_username = "username";
$user_password = "pass";
$user_database = "database";

$domainpath = "xxx";
$list = "xxxx"
?>

(((admin.php)))

<?php

include("config.php");

$connect = mysql_connect("$user_hostname", "$user_username",
"$user_password");
mysql_select_db("$user_database", $connect);

$PHP_SELF = str_replace(stristr($PHP_SELF, '?'),'',$PHP_SELF);

echo "<center><table border=1><tr><td align=center><b>First Name</b></td>
<td align=center><b>Last Name</b></td><td align=center><b>Username</b></td>
<td align=center><b>Password</b></td><td align=center><b>Email
Address</b></td>
<td align=center><b>Option</b></td></tr></center>";

$sql = "SELECT * FROM users ORDER BY id";
$result = @mysql_query($sql) or die(mysql_error());
while($row = mysql_fetch_array($result)) {

echo
"<tr><td>".$row['fname']."</td><td>".$row['lname']."</td><td>".$row['usernam
e']."</td>
<td>".$row['password']."</td><td>".$row['email']."</td>
<td><a href=$PHP_SELF?action=edit&id=".$row['id'].">Edit</a> |
<a href=$PHP_SELF?action=delete&id=".$row['id'].">Delete</a></td></tr>";

}

if($action == "delete") {

echo "<b>Are you sure you want to delete this user?<p>
<a href=$PHP_SELF?delete=final&id=$id>Yes</a><p>
<a href=$PHP_SELF>No</a><p>";
exit;

} else if($delete == "final" && isset($id)) {

$sql = "DELETE FROM users WHERE id = '$id'";
$result = @mysql_query($sql) or die(mysql_error());

echo "<center>User successfully deleted</center>";
exit;

}

if(!$submit && $action == "edit" && isset($id)) {

$sql = "SELECT * FROM users WHERE id = '$id'";
$result = @mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_array($result);

echo "<center><form method=Post action=$PHP_SELF><table><tr><td>First
Name</td>
<td><input type=text name=fname
value=\"".$row['fname']."\"></td></tr><tr><td>Last Name</td>
<td><input type=text name=lname
value=\"".$row['lname']."\"></td></tr><tr><td>Username</td>
<td><input type=text name=username
value=\"".$row['username']."\"></td></tr><tr><td>Password</td>
<td><input type=password name=password
value=\"".$row['password']."\"></td></tr><tr><td>Email Address</td>
<td><input type=text name=email value=\"".$row['email']."\"></td></tr><tr>
<td><input type=submit name=submit value=submit>
<input type=hidden name=action value=edit><input type=hidden name=id
value=$id></td></tr>";

} else if($submit && $action == "edit" && isset($id)) {

if(!$submit && $action == "edit" && isset($id) && !empty($fname) or
!empty($lname)
or !empty($username) or !empty($password)
or !empty($email)) {

$sql = "UPDATE users SET fname='$fname', lname='$lname',
username='$username', password='$password',
email='$email' WHERE id = '$id'";
$result = @mysql_query($sql) or die(mysql_error());

echo "<center>User successfully updated.</center>";

}

}

?>



Relevant Pages

  • Re: PHP.exe closing on exit
    ... All I want to do is test PHP scripts on my Windows XP client machine. ... I can't disable 'close on exit', ... > your script exits, the PHP shell that launched it has no purpose, so it ...
    (comp.lang.php)
  • Session losing variables?
    ... I have a script start.php and a second script proceed.php ... <?PHP ... // Strings match, so open logfile, exit if this fails. ...
    (comp.lang.php)
  • Re: multipul ip ban
    ... Can u give me any good sites that I can learn more about php? ... with the ip ban script? ... > /* open file for readonly */ ... > /* page and exit the script */ ...
    (alt.php)
  • Re: PHP.exe closing on exit
    ... > doesn't seem to have the traditional options of an MS-DOS program. ... your script exits, the PHP shell that launched it has no purpose, so it ... I'd expect a language interpreter to exit once I'm done with it ...
    (comp.lang.php)
  • php session problem in IE 6.0
    ... i have this log in script from a book that uses session variable to ... $result = mysql_query($sql, $conn); ...
    (comp.lang.php)