Je veux juste simplifier ce que je fais avant, ayant plusieurs fichiers php pour toutes les données à répertorier. Voici mon formulaire HTML:avoir des problèmes dans mysql if déclaration
<table border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#D3D3D3">
<tr>
<form name="formcheck" method="post" action="list.php" onsubmit="return formCheck(this);">
<td>
<table border="0" cellpadding="3" cellspacing="1" bgcolor="">
<tr>
<td colspan="16" height="25" style="background:#5C915C; color:white; border:white 1px solid; text-align: left"><strong><font size="3">List Students</td>
</tr>
<tr>
<td width="30" height="35"><font size="3">*List:</td>
<td width="30"><input name="specific" type="text" id="specific" maxlength="25" value="">
</td>
<td><font size="3">*By:</td>
<td>
<select name="general" id="general">
<font size="3">
<option>Year</option>
<option>Address</option>
</select></td></td>
</tr>
<tr>
<td width="10"><input align="right" type="submit" name="Submit" value="Submit" > </td>
</tr>
</form>
</table>
Et voici l'action de forme:
<?php
$con = mysql_connect("localhost","root","nitoryolai123$%^");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("school", $con);
$gyear= $_POST['general'];
if ("YEAR"==$_POST['general']) {
$result = mysql_query("SELECT * FROM student WHERE YEAR='{$_POST["specific"]}'");
echo "<table border='1'>
<tr>
<th>IDNO</th>
<th>YEAR</th>
<th>LASTNAME</th>
<th>FIRSTNAME</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['IDNO'] . "</td>";
echo "<td>" . $row['YEAR'] . "</td>";
echo "<td>" . $row['LASTNAME'] . "</td>";
echo "<td>" . $row['FIRSTNAME'] . "</td>";
echo "</tr>";
}
echo "</table>";
}
mysql_close($con);
?>
S'il vous plaît aider, comment puis-je assimilent l'année (colonne dans la base de données de MySQL) et la case d'option (général).
if ("YEAR"==$_POST['general'])
corrigez-moi si je me trompe.
qu'attendez-vous $ _POST [ «général»] être ?? donne un bon exemple. Si vous cherchez des dates alors effectuez une recherche google pour "date fonction php". – pinaki
espérons que vos détails mysql_connect ne sont pas réels – Unreason
Vous devriez * jamais * utiliser le compte racine MySQL pour l'interrogation dans vos scripts, vous devez créer un compte utilisateur séparé pour cela et utiliser le compte root uniquement pour la maintenance de la base de données. – wimvds