Ok, I have a database with employee names, id numbers and crew id's, and rand_order()..
I am making a page so that admin can edit,delete,update,add employee info. and then have the ability to draw an employee "out of a hat" if you will, randomly.
the rand_order is for a "random" drawing from the database. that part is done, the add employee part is done, but i can't get the update/delete portion to work.
here is the sql dump:
# Host: localhost
# Generation Time: Jun 30, 2004 at 01:02 PM
# Server version: 4.0.16
# PHP Version: 4.1.2
#
# Database : `safety`
#
# --------------------------------------------------------
#
# Table structure for table `EmpInfo`
#
CREATE TABLE `EmpInfo` (
`ID` int(11) NOT NULL auto_increment,
`Employee` varchar(255) NOT NULL default '',
`EmployeeID` int(11) NOT NULL default '0',
`CrewID` int(11) NOT NULL default '0',
`rand_order` float default NULL,
PRIMARY KEY (`ID`,`EmployeeID`)
) TYPE=MyISAM AUTO_INCREMENT=276 ;
*************************
and here is the update.php code:
*************************
<?
include("dbinfo.inc.php");
$ID=$_GET['ID'];
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT Employee,EmployeeID,CrewID FROM EmpInfo WHERE ID=$ID";
$result=mysql_query($query);
$num=mysql_num_rows($result);
mysql_close();
$i=0;
while ($i < $num) {
$Employee=mysql_result($result,$i,"Employee");
$EmployeeID=mysql_result($result,$i,"EmployeeID");
$CrewID=mysql_result($result,$i,"CrewID");
?>
<form action="updated.php" method="post">
<input type="hidden" name="ud_ID" value="<? echo "$ID"; ?>">
Employee: <input type="text" name="ud_Employee" value="<? echo "$Employee"?>"><br>
Employee ID: <input type="text" name="ud_EmployeeID" value="<? echo "$EmployeeID"?>"><br>
Crew ID: <input type="text" name="ud_CrewID" value="<? echo "$CrewID"?>"><br>
<input type="Submit" value="Update">
</form>
<?
++$i;
}
?>