<?php
include ('logue.php'); 
include ('entete2.php');
include ('entete.php');
include ('ressource.php');

echo"
<style>
input {
border:1px solid #7E7E7E;
background-color:#000000;
font-family:'trebuchet ms',sans-serif;
color:white;
}
textarea {
border:1px solid #7E7E7E;
background-color:#000000;
font-family:'trebuchet ms',sans-serif;
color:white;
}
select, option {
background-color:#000000;
color:white;
}
</style>
<STYLE TYPE=text/css>
.Style1 {color: #0000FF}
.Style2 {color: #FF0000}
.Style3 {color: #00CC00}
</STYLE>";
echo"<div align=\"center\"><form name=\"colo\" method=\"post\" action=\"colonie.php\" target=\"_parent\">
<table align=\"center\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
   <tr>
     <td width=\"100\" rowspan=\"2\" valign=\"middle\">
       <div align=\"center\">
         <input name=\"page\" value=\"" . $PHP_SELF . "\" type=\"hidden\" id=\"page\">
         <select name=\"idcolo\" onchange=submit()>";
include ('colo2.php'); 

$id = $_POST["id"];

$sql = "SELECT nom FROM matgraph_vaisseaux WHERE id='".intval($id)."' ";
$res = mysql_query($sql)or die('erreur sql<br>'.$sql.'<br>'.mysql_error());
$row = mysql_fetch_array($res); 

$sql6 = "SELECT idvaisseau, nombre FROM matgraph_mobil WHERE idvaisseau = '".intval($id)."'" ; 
$res6 = mysql_query($sql6) or die('erreur sql<br>' . $sql6 . '<br>' . mysql_error()) ;
$num6 = mysql_num_rows($res6);
if ( $num6 > 0 ) {
echo"<br><p align=\"center\">Vous avez au moins un \"$row[nom]\" de construit.";
exit;}

$sql2 = "SELECT nbre FROM matgraph_nbrevaisseaux WHERE vaisseau='".intval($id)."' AND nbre != '0'";
$res2 = mysql_query($sql2)or die('erreur sql<br>'.$sql2.'<br>'.mysql_error());
$num2 = mysql_num_rows($res2);
if ( $num2 > 0 ) {
echo"<br><p align=\"center\">Vous avez au moins un \"$row[nom]\" de construit.";
exit;}

$sql4 = "DELETE FROM matgraph_vaisseaux WHERE id = '".intval($id)."' AND iduser='$idlogin'";
$res4 = mysql_query($sql4)or die('erreur sql<br>'.$sql4.'<br>'.mysql_error());

$sql6 = "DELETE FROM matgraph_nbrevaisseaux WHERE vaisseau='".intval($id)."' AND user=$idlogin" ; 
$res6 = mysql_query($sql6) or die('erreur sql<br>' . $sql6 . '<br>' . mysql_error()) ;

echo '<script language="javascript" type="text/javascript">
<!--
window.location.replace("chantier.php");
-->
</script>';
?>