Vote

Contenu du snippet

bon c mon 1ere code php alors... soyllé cool meme si c pas bien codé ^^ c qu'une 1ere ;).
c'est un sondage, il y a des truk bien dans mon code ou il y a tout a jéter ?

Source / Exemple :


SONDAGE.PHP
¯¯¯¯¯¯¯¯¯¯¯¯¯
Ca c'est just le FORM, pas de code php la dedans... je savez pâs si il fallé le métre donc dans le doute je l'est mi ^^
-----------------------------------------------------------------------------------------
<html>
<body>
<p>&nbsp;</p>
<p>&nbsp;</p>
<form action="sondagee.php">
  <table border="1" width="22%" height="100">
    <tr>
      <td width="45%" height="19">
        <p align="center">POUR</td>
      <td width="29%" height="19">
        <p align="center">CONTRE</td>
      <td width="42%" height="19"></td>
    </tr>
    <tr>
      <td width="45%" height="19">
        <p align="center"><input type="radio" value="p1" name="sondage" checked></td>
      <td width="29%" height="19">
        <p align="center"><input type="radio" name="sondage" value="p4"></td>
      <td width="42%" height="19">Vote 1</td>
    </tr>
    <tr>
      <td width="45%" height="19">
        <p align="center"><input type="radio" name="sondage" value="p2"></td>
      <td width="29%" height="19">
        <p align="center"><input type="radio" name="sondage" value="p5"></td>
      <td width="42%" height="19">Vote 2</td>
    </tr>
    <tr>
      <td width="45%" height="19">
        <p align="center"><input type="radio" name="sondage" value="p3"></td>
      <td width="29%" height="19">
        <p align="center"><input type="radio" name="sondage" value="p6"></td>
      <td width="42%" height="19">Vote 3</td>
    </tr>
    <tr>
      <td width="24%" colspan="2" height="1">
        <p align="center"><input type="submit" value="Valider"></td>
      <td width="42%" height="1"></td>
    </tr>
  </table>
</form>
</body>
</html>

-----------------------------------------------------------------------------------------Sondagee.php
¯¯¯¯¯¯¯¯¯¯¯¯¯
Voila c la ou est tout le code php
-----------------------------------------------------------------------------------------
<?
include('connect.inc');
$connect=mysql_connect($hote,$user,$pass);
$base = mysql_select_db("sondage");
$mareq="select * from ".$sondage."";
$resultat=mysql_query($mareq);
$nbre=mysql_numrows($resultat);
$nb = $nbre + 1;
mysql_query("insert into $sondage(nb) values ('$nb')");
for ($i = 1; $i <=6; $i++)
	{
		$pi = "p$i";
		$mareq ="select * from p$i";
		$resultat=mysql_query($mareq);
		$$pi = mysql_numrows($resultat);
	}
?>
<html>
<body>

<p>&nbsp;</p>
<p>&nbsp;</p>

<form action="sondage.php">
  <table border="1" width="22%">
    <tr>
      <td width="37%">POUR</td>
      <td width="25%">CONTRE</td>
      <td width="27%">&nbsp;</td>
    </tr>
    <tr>
      <td width="37%"><? echo $p1; ?>
	  </td>
      <td width="25%"><? echo $p4; ?></td>
      <td width="27%">Vote 1</td>
    </tr>
    <tr>
      <td width="37%"><? echo $p2; ?></td>
      <td width="25%"><? echo $p5; ?></td>
      <td width="27%">Vote 2</td>
    </tr>
    <tr>
      <td width="37%"><? echo $p3; ?></td>
      <td width="25%"><? echo $p6; ?></td>
      <td width="27%">Vote 3</td>
    </tr>
    <tr>
      <td width="39%" colspan="2">
        <form method="POST" action="--WEBBOT-SELF--">
  <p><a href="sondage.php"><input type="button" value="Changer de vote" name="B3"></a></p>
</form>
      <td width="27%">&nbsp;</td>
    </tr>
  </table>
</form>
<p><a href="sondage.php">test</a></p>
</body>
</html>

Conclusion :


Alors vous en pancé koi ? (n'oublié pas que c mon 1ere code :-/)

A voir également

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.