I’ve attached a screenshot of my databse table as well as my code to this post for better clarification. Here’s my issue…The code I’ve posted works great. It will pull data from my DB & display it in a web browser form. On lines 177 through 187, this code is there I need the help. At this time the code between those lines pulls the names from the clerk_names table & randomly displays them in the “Automated Clerk Assignment” field. Each of the clerk names is set to active by the 1 in the active column. How can I edit this code so once the SQL pulls the name from the DB & displays it in my form, & then I submit it by clicking the “Place Assignments” button, the clerk name that is displayed in the form is set to a 0 in the active column?
SO basically, I just need the 1 to be updated to a 0 in the “active” column for the clerk name that is randomly displayed in the form. Thanks for any help!
[php]
To go to the main page click here.
<?php $page_title = 'Edit a Record'; $con = mysql_connect("localhost","uname","password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("flow", $con); ini_set('display_errors',1); error_reporting(E_ALL); if ( (isset($_GET['id'])) && (is_numeric($_GET['id'])) ) { $id = $_GET['id']; } elseif ( (isset($_POST['id'])) && (is_numeric($_POST['id'])) ) { $id = $_POST['id']; } else { // No valid ID, kill the script. echo 'Page Error
This page has been accessed in error.
The assignment has been submitted successfully!
An email containing all this information has been sent to the assigned employee.
'; switch($_REQUEST['employee']) { case "John Doe": $Email = "[email protected]"; break; case "Jane Doe": $Email = "[email protected]"; break; case "Greg Johnson": $Email = "[email protected]"; break; default: echo "Error, no employee selected!!!"; break; } $Message = "Someone Has Been Assigned to You Below.\n \nName : ${_REQUEST['fname']} ${_REQUEST['mname']} ${_REQUEST['lname']} \nitem No : ${_REQUEST['item']} \nemployee : ${_REQUEST['employee']} \nLocation : ${_REQUEST['location']}"; $Subject = "Assignment"; $Headers = "From: [email protected] \n"; if (mail($Email, $Subject, $Message, $Headers)) exit(); } else { echo 'Error!
The following error(s) occurred:
';
foreach ($errors as $msg) {
echo " - $msg
\n";
}
echo '
If you continue to get this error call IT.
echo ’
This section assigns the it to an employee & a clerk. Your person will not be notified until the employee enters the information.
item No: |
Location: |
|
First Name: |
Middle Name: |
Last Name (Corporation/Partnership): |
Assign To This employee: John Doe Jane Doe Greg Johnson |
';
} else { // Not a valid user ID.
echo ‘
Page Error
This page has been accessed in error.
}
mysql_close(); // Close the database connection.
?>
<?php $mysqli = new mysqli('localhost', 'uname', 'password', 'flow'); $sql = "SELECT names FROM clerk_names WHERE active = '1' ORDER BY RAND() LIMIT 1"; $res = $mysqli->query($sql); $row = $res->fetch_row(); $randomName = $row[0]; $res->free(); ?>[/php]