- Joined
- Feb 8, 2005
- Messages
- 34
- Reaction score
- 0
I have to do this random list of combination of employees for school, i use MySQL and PHP, the code that i have is this:
And this is the table, it is only made for using it on mondays:
So what i wanna do is drop a random couple of employees every time on every location... but the thing is that every employee has different requierements:
-Cook
-Wisdom
-Helpfull
And some of them cant be with others, like this:
-Cook should always be with Wisdom
-Cook mustn't be with Helpfull
-Wisdom could be with Wisdom
-Helpfull could be with Wisdom
-Helpfull may be with Helpfull,
That's the most difficult part, i don't know how to put: "mustn't be with","could be" in php...
The database "employee" is this:
Please help me cos i need it for next friday!!!
PHP:
<?
// Settings
$mysql_server = "localhost";
$mysql_user = "user";
$mysql_password = "pass";
$mysql_database = "employees";
// Conectarse de nuevo
include 'empleo-conect.php';
// Conect Database
$connection = mysql_connect("$mysql_server","$mysql_user","$mysql_password") or die ("Can't connect.");
$db = mysql_select_db("$mysql_database") or die ("Can't connect.");
?>
<?
//$res=mysql_query("SELECT Name, Req FROM name");
$con = mysql_query("SELECT Req FROM name");
$nom = mysql_query("SELECT Name FROM name");
if ($con="Danger")
{
$con=$p;
}
if ($con="Suspect")
{
$con=$s;
}
if ($con="Good")
{
$con=$c;
}
?>
Code:
<table width="75%" border="1">
<tr>
<td>Location/time</td>
<td>Morning</td>
<td>Dust</td>
<td>Afternoon</td>
</tr>
<tr>
<td>Location1</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Location2</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Location3</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Location4</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Location5</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Location6</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
-Cook
-Wisdom
-Helpfull
And some of them cant be with others, like this:
-Cook should always be with Wisdom
-Cook mustn't be with Helpfull
-Wisdom could be with Wisdom
-Helpfull could be with Wisdom
-Helpfull may be with Helpfull,
That's the most difficult part, i don't know how to put: "mustn't be with","could be" in php...
The database "employee" is this:
Code:
CREATE TABLE `name` (
`Name` varchar(20) NOT NULL,
`Req` varchar(11) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
INSERT INTO `nombre` VALUES ('Mariah', 'Cook');
and other names like that...