<?php
// assign the values for database access
$host = "localhost";
$user = "your_user_name";
$password = "your_password";
$db_name = "database_name";
$table_name = "user_registration";
session_start( );
// initializing the record count
// and session variable to keep track of current record
if (!isset($_SESSION['current_row']))
{
$_SESSION['current_row'] = 1;
}
// connecting to the database on battcave.com
$link = mysql_connect($host, $user, $password);
// constructing the query string
$query_string = "SELECT * FROM $table_name";
// executing the query
$result_set = mysql_db_query($db_name, $query_string, $link);
// obtaining the number of rows in the record set
$number_rows = mysql_num_rows($result_set);
// Now we have our code that handles the command
buttons
// the block of code to move the admin to the previous record
//
// if the First button has been pressed
if ($cmdFirst != "")
{
// setting the row counter to 1
$_SESSION['current_row'] = 1;
}
// the block of code to move the admin to the
previous record
// if the Previous button has been pressed
if ($cmdPrevious != "")
{
// making certain the admin is not already
at the first record
if ($_SESSION['current_row'] == 1)
{
echo("<font size=5>You are already at the
first record!</font>");
}
else
{
$_SESSION['current_row'] = $_SESSION['current_row']
- 1;
}
}
// the block of code to move the admin to the next
record
// if the Next button has been pressed
if ($cmdNext != "")
{
// making certain the admin is not already
at the last record
if ($_SESSION['current_row'] == $number_rows)
{
echo("<font size=5>You are already at the
last record!</font>");
}
else
{
$_SESSION['current_row'] = $_SESSION['current_row']
+ 1;
}
}
// if the Last button has been pressed
if ($cmdLast != "")
{
// setting the row counter to the last
record
$_SESSION['current_row'] = $number_rows;
}
// if the Delete button has been pressed
if ($cmdDelete != "")
{
// setting a variable to use for the delete
query
$user_id_number = $_SESSION['current_user_id'];
// developing the deletion query string based
on the user_id
$delete_string = "DELETE FROM $table_name
WHERE (user_id = '$user_id_number')";
// deleting the entry
$delete_set = mysql_db_query($db_name, $delete_string,
$link);
// decrementing the total number of entries
due to the deletion
$number_rows--;
// change the current record and display
based on where you are
if ($_SESSION['current_row'] == 1)
{
$_SESSION['current_row'] = 2;
}
else
{
$_SESSION['current_row'] = $_SESSION['current_row']
- 1;
}
}
// a variable for printing
$current_row_number = $_SESSION['current_row'];
// go to this current row
mysql_data_seek($result_set, $_SESSION['current_row']);
// and retrieve it into an array
$row = mysql_fetch_row($result_set);
?>
<html>
<head>
<title>Admin Browser for User Registration Web</title>
</head>
<body bgcolor = "00bbdd" text="004466" link="004466" vlink="007799">
<form action="admin_browser.php" method=post>
<h2>Admin Browser for User Registration</h2>
<table>
<tr>
<td><font size = 4 color=004466>First Name:</font>
</td>
<td><input type=text name="txt_first_name" size=20 value = "<?php echo
$row[1]; ?>">
</td>
</tr>
<tr>
<td><font size = 4 color=004466>Last Name:</font>
</td>
<td><input type=text name="txt_last_name" size=20 value = "<?php echo
$row[2]; ?>">
</td>
</tr>
<tr>
<td><font size = 4 color=004466>EMail Address:</font>
</td>
<td><input type=text name="txt_email" size=50 value = "<?php echo $row[3];
?>">
</td>
</tr>
<tr>
<td><font size = 4 color=004466>Password:</font>
</td>
<td><input type=password name="txt_password" size=50 value = "<?php echo
$row[4]; ?>">
</td>
</tr>
<tr>
<td> </td>
<td></td>
</tr>
<tr>
<td><font size = 4 color=004466>Interests:</font>
</td>
<td><input type=checkbox name="chk_php" value=1
<?php if (($row[5]) == 1 ) echo 'checked'; ?>>
<font size = 4 color=004466>PHP</font>
</td>
</tr>
<tr>
<td>
</td>
<td><input type=checkbox name="chk_jsp" value=1
<?php if (($row[6]) == 1 ) echo 'checked'; ?>>
<font size = 4 color=004466>JSP</font>
</td>
</tr>
<tr>
<td>
</td>
<td><input type=checkbox name="chk_mysql" value=1
<?php if (($row[7]) == 1 ) echo 'checked'; ?>>
<font size = 4 color=004466>MySQL</font>
</td>
</tr>
<tr>
<td> </td>
<td></td>
</tr>
<tr>
<td><font size = 4 color=004466>Credit Card:</font>
</td>
<td><select name="sel_credit_card">
<option value="Discover" <?php if (($row[8]) == 'Discover') echo
'selected'; ?>>Discover
<option value="MasterCard" <?php if (($row[8]) == 'MasterCard') echo
'selected'; ?>>Mastercard
<option value="Visa" <?php if (($row[8]) == 'Visa') echo 'selected';
?>>Visa
</select>
</td>
</tr>
<tr>
<td> </td>
<td></td>
</tr>
<tr>
<td><font size = 4 color=004466>Education:</font>
</td>
<td><input type=radio name="rb_education" value="NoCollege"
<?php if (($row[9]) == 'NoCollege') echo 'checked'; ?>>
<font size = 4 color=004466>No College</font><br>
<input type=radio name="rb_education" value="College"
<?php if (($row[9]) == 'College') echo 'checked'; ?>>
<font size = 4 color=004466>College</font><br>
<input type=radio name="rb_education" value="Masters"
<?php if (($row[9]) == 'Masters') echo 'checked'; ?>>
<font size = 4 color=004466>Masters</font><br>
<input type=radio name="rb_education" value="PhD"
<?php if (($row[9]) == 'PhD') echo 'checked'; ?>>
<font size = 4 color=004466>Ph.D.</font>
</td>
</tr>
<tr>
<td> </td>
<td></td>
</tr>
<tr>
<td align = right>
<?php echo("<font size=4>Record $current_row_number</font>"); ?>
</td>
<td align = left>
<?php echo("<font size=4>of $number_rows</font>"); ?>
</td>
</tr>
<tr>
<td align = right>
<input type = submit name="cmdFirst" value="First">
<input type = submit name="cmdPrevious" value="Previous">
</td>
<td align = left>
<input type = submit name="cmdNext" value="Next">
<input type = submit name="cmdLast" value="Last">
</td>
</tr>
<tr>
<td align = right>
</td>
<td align = left>
<input type = submit name="cmdDelete" value="Delete">
</td>
</tr>
</table>
</form>
<?php
// establishing a session variable that can be used
to
// obtain the user_id of the record currently displayed
// to be accessed when we return
// this will be important for deletions and modifications
$_SESSION['current_user_id'] = $row[0];
mysql_close($link);
?>
</body>
</html> |