1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
| <?php
session_start();
?>
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>essai1</title>
<style type="text/css">
<!--
body { background: url(../semaine.gif) no-repeat;}
</style>
<script type="text/javascript">
function onclick_page(event)
{
var x = event.clientX;
var y = event.clientY;
window.open("libelle.php?x="+x+"&y="+y,"choix","width=400 height=300" );
}
</script>
</head>
<body onDblclick="onclick_page(event)" >
<?php
if ( isset($_GET['libel'])) {$_SESSION['titre'] = $_GET['libel'];}
?>
<?php
if(isset( $_GET['x']))
{
$x = $_GET['x'];
$y = $_GET['y'];
$nom = $_SESSION['titre'];
$type= $_GET['choix'];
$fin=0;
}
// Déclaration des paramètres de connexion.
$host = 'localhost';
$user = 'root';
$bdd = 'eurisol';
$passwd = '';
// Connexion au serveur
$link = mysql_connect($host, $user,$passwd) or die("erreur de connexion au serveur");
mysql_select_db($bdd) or die("erreur de connexion a la base de donnees");
//Calcul du "y" 4h avant soit 150px
$req= "SELECT * FROM tache WHERE type='mp' " ;
$sql = mysql_query($req);
$retour = mysql_query("SELECT COUNT(*) AS nbre_entrees FROM tache");
$donnees = mysql_fetch_array($retour);
while($res = mysql_fetch_array($sql) && $fin==0 )
{
$diff =$_GET['y'] - $res['y'];
if($diff>=150 )
{ $fin=1;
echo "boucle if possible!";}
else {
?> <script language="javascript">alert("votre demande a été rejeté faute de matiere premiere!");</script><?php
echo"pf impossible"; }
}
//Insertion ds ma table
if( isset($type) && isset($x) && $x != 0 && $y != 0)
{ echo "insertion possible???";
$insert="INSERT INTO tache (x, y, nom, type) VALUES ('$x', '$y', '$nom', '$type')";
mysql_query($insert) or die ('ERREUR SQL ! :' .$insert.'<br>' .mysql_error()); }
//Creation et envoi de la requete : affichage de ma div
$query = "SELECT * FROM tache";
$result = mysql_query($query);
while($donnees = mysql_fetch_array ($result)) //Ma table est rangée dans un array:donnees
{
$id=$donnees['id'];
$width= $donnees['x'];
$height= $donnees['y'];
if($donnees['type']=='pf')
{$bg='green';}
else{$bg='pink';}
//affichage de ma div
if ($largeur != 0 && $hauteur!= 0)
{
?>
<div id="apDiv<?php echo $id;?> " style="position:absolute; width:100px; height:30px; left:<?php echo $largeur;?>px;
top:<?php echo $hauteur;?>px;
background-color:<?php echo $bg;?>;"><?php echo $donnees['nom'];?></div>
<?php
}
}
mysql_close();
?>
</body>
</html> |