<?php
echo"
<STYLE TYPE=text/css>
A.menulink2 {
width: 150px;
text-decoration: none;
font-family:Verdana;
font-size:11px;
color: #FF3300;
BORDER: none;
border: solid 1px #000000;
}
A.menulink2:hover {
border: solid 1px #000000;
background-color:#000000;
}
</STYLE>";

if(isset($_POST['titre']) && isset($_POST['texte'])){
	$titre = $_POST["titre"];
	$texte = $_POST["texte"];
	$on = $_POST["on"];

	$sql = "UPDATE matgraph_commentaires SET titre='$titre',texte='$texte', onoff='$on' WHERE id='1' ";
	$res = mysql_query($sql)or die('erreur sql<br>'.$sql.'<br>'.mysql_error());
}
echo"<br><center><h4>Aperçu du message</h4></center><br>
<table width=\"659\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\">
  <tr>
    <td width=\"251\"><div align=\"center\">Titre : </div></td>
    <td width=\"375\"><div align=\"center\">Message : </div></td>
    <td width=\"25\">On / Off</td>
	<td width=\"25\">Envoyer</td>
  </tr>";
$req = "SELECT * FROM matgraph_commentaires ORDER by id = 1 DESC";
$res = mysql_query($req) or die('Erreur SQL! <br>'.$req.'<br>'.mysql_error());
$num = mysql_num_rows($res);
if ( $num > 0 ) {
  While ( $row = mysql_fetch_array($res) ) {
echo"<form name=\"maj\" method=\"post\" action=\"index.php?action=message_apercu\" target=\"_parent\"><tr>
    <td><div align=\"center\"><input type=\"text\" name=\"titre\" value=\"$row[titre]\"></div></td>
    <td><div align=\"center\"><textarea name=\"texte\" rows=10 COLS=40>$row[texte]</textarea></div></td>
	
    <td><select name=\"on\">
    <option value=\"1\">On</option>
    <option value=\"0\""; if($row[onoff] == 0) { echo" selected"; } echo">Off</option>
  </select></td>
  <td><input type=\"submit\" name=\"Submit\" value=\"Envoyer\"></td>
	</form>";
	
	}}
  echo"</tr>
</table><br/>";
  
  
?>
