Code PHP qui n'affiche rien
Résolu
Billou87
-
Billou87 -
Billou87 -
Bonjour,
Voici mon code PHP :
<?php
if(isset($_POST['table']))
{
$select="selected=selected";
$table = mysql_real_escape_string($_POST['table']);
$sql = mysql_query('SELECT * FROM '.$table.'');
?>
<form method="post" action="">
<table cellpadding="0" cellspacing="0">
<tr>
<td></td>
<td>
<select name="table">
<option value="" >-- Choisissez un type d'examen --</option>
<option value="fevg" <?php if($table == "fevg") echo $select; ?> >FEVG</option>
<option value="gspect, gspect2" <?php if($table == "gspect, gspect2") echo $select; ?> >G-SPECT</option>
<option value="gamma" <?php if($table == "gamma") echo $select; ?> >Gamma Camera</option>
</select>
</td>
<td>
<select name="critere">
<option value="" >-- Choisissez un critere --</option>
<?php while($row = mysql_fetch_field($sql))
{
echo '<option value='. $row -> name .'>';
echo ''. $row -> name .'';
echo '</option>';
}?>
</select>
</td>
<td><input type="submit" value="OK"/></td>
</tr>
</table>
</form>
<?php}
else
{?>
<form method="post" action="">
<table cellpadding="0" cellspacing="0">
<tr>
<td></td>
<td>
<select name="table">
<option value="">-- Choisissez un type d'examen --</option>
<option value="fevg">FEVG</option>
<option value="gspect, gspect2">G-SPECT</option>
<option value="gamma">Gamma Camera</option>
</select>
</td>
<td><input type="submit" value="OK"/></td>
</tr>
</table>
</form>
<?php } ?>
Lorsque je veux charger la page, elle n'affiche rien du tout ! Je ne vois pas quelle erreur cela peut-être, j'ai vérifié mon code une bonne dizaine de fois !
Voici mon code PHP :
<?php
if(isset($_POST['table']))
{
$select="selected=selected";
$table = mysql_real_escape_string($_POST['table']);
$sql = mysql_query('SELECT * FROM '.$table.'');
?>
<form method="post" action="">
<table cellpadding="0" cellspacing="0">
<tr>
<td></td>
<td>
<select name="table">
<option value="" >-- Choisissez un type d'examen --</option>
<option value="fevg" <?php if($table == "fevg") echo $select; ?> >FEVG</option>
<option value="gspect, gspect2" <?php if($table == "gspect, gspect2") echo $select; ?> >G-SPECT</option>
<option value="gamma" <?php if($table == "gamma") echo $select; ?> >Gamma Camera</option>
</select>
</td>
<td>
<select name="critere">
<option value="" >-- Choisissez un critere --</option>
<?php while($row = mysql_fetch_field($sql))
{
echo '<option value='. $row -> name .'>';
echo ''. $row -> name .'';
echo '</option>';
}?>
</select>
</td>
<td><input type="submit" value="OK"/></td>
</tr>
</table>
</form>
<?php}
else
{?>
<form method="post" action="">
<table cellpadding="0" cellspacing="0">
<tr>
<td></td>
<td>
<select name="table">
<option value="">-- Choisissez un type d'examen --</option>
<option value="fevg">FEVG</option>
<option value="gspect, gspect2">G-SPECT</option>
<option value="gamma">Gamma Camera</option>
</select>
</td>
<td><input type="submit" value="OK"/></td>
</tr>
</table>
</form>
<?php } ?>
Lorsque je veux charger la page, elle n'affiche rien du tout ! Je ne vois pas quelle erreur cela peut-être, j'ai vérifié mon code une bonne dizaine de fois !
A voir également:
- Code PHP qui n'affiche rien
- Code ascii - Guide
- Code puk bloqué - Guide
- Comment déverrouiller un téléphone quand on a oublié le code - Guide
- Code activation windows 10 - Guide
- Code blocks - Télécharger - Langages
4 réponses
Tout d'abord est ce que tu as bien en bien un serveur Apache avec le module Php qui fonctionne correctement ?
ensuite tu devrais essayer un simple echo "toto"; sans If ou autre condition.
Et la fin de ton fichier n'est pas très claire je ne pense pas que tu puisse faire :
....
else
{
?>
hltml
html
<php?
}
?>
je pense que tu devrais mettre tous l'html en php dans un echo
ensuite tu devrais essayer un simple echo "toto"; sans If ou autre condition.
Et la fin de ton fichier n'est pas très claire je ne pense pas que tu puisse faire :
....
else
{
?>
hltml
html
<php?
}
?>
je pense que tu devrais mettre tous l'html en php dans un echo
Bonjour,
****************************************
$sql = mysql_query('SELECT * FROM '.$table.'');
****************************************
Je ne vois pas les guillemets ouvrant ?
****************************************
$sql = mysql_query('SELECT * FROM '.$table.'');
****************************************
Je ne vois pas les guillemets ouvrant ?
JFS77 -> mon fichier est "include" dans un autre fichier index.php donc je n'ai pas besoin de rajouter de balise <html>. Concernant le serveur Apache, je tourne sur WampServer, et je n'ai pas eu de problème jusqu'à présent (sauf là apparemment).
Pour la fin du fichier, j'ai pas tout saisi ce que tu as écris !
Et je vais tenter avec les echo 'html' en attendant :)
Cybertipunch -> j'ai déja essayé avec les simples quotes mais sans succès
Pour la fin du fichier, j'ai pas tout saisi ce que tu as écris !
Et je vais tenter avec les echo 'html' en attendant :)
Cybertipunch -> j'ai déja essayé avec les simples quotes mais sans succès
<?php if(isset($_POST['table']))
{
$table = $_POST['table'];
$select = "selected=selected";
$sql = mysql_query('SELECT * FROM '.$table.'');
?> <form method="post" action="">
<table cellpadding="0" cellspacing="0">
<tr>
<td></td>
<td>
<select name="table">
<option value="" >-- Choisissez un type d'examen --</option>
<option value="fevg" <?php if($table == "fevg") echo $select; ?> >FEVG</option>
<option value="gspect, gspect2" <?php if($table == "gspect, gspect2") echo $select; ?> >G-SPECT</option>
<option value="gamma" <?php if($table == "gamma") echo $select; ?> >Gamma Camera</option>
</select>
</td>
<td>
<select name="critere">
<option value="" >-- Choisissez un critere --</option>
<?php while($row = mysql_fetch_field($sql))
{
echo '<option value='. $row -> name .'>';
echo ''. $row -> name .'';
echo '</option>';
}?>
</select>
</td><td><input type="submit" value="OK"/></td>
</tr>
</table>
</form>
<?php }
else{ ?>
<form method="post" action="">
<table cellpadding="0" cellspacing="0">
<tr>
<td></td>
<td>
<select name="table">
<option value="">-- Choisissez un type d'examen --</option>
<option value="fevg">FEVG</option>
<option value="gspect, gspect2">G-SPECT</option>
<option value="gamma">Gamma Camera</option>
</select>
</td>
<td><input type="submit" value="OK"/></td>
</tr>
</table>
</form>
<?php } ?>
Prob résolu avec ce code, mais je n'arrive toujours pas a comprendre pourquoi il ne fonctionnait pas avant.
J'ai refait pas à pas la procédure et cela a marché. Si ca vous dit de regarder ....
{
$table = $_POST['table'];
$select = "selected=selected";
$sql = mysql_query('SELECT * FROM '.$table.'');
?> <form method="post" action="">
<table cellpadding="0" cellspacing="0">
<tr>
<td></td>
<td>
<select name="table">
<option value="" >-- Choisissez un type d'examen --</option>
<option value="fevg" <?php if($table == "fevg") echo $select; ?> >FEVG</option>
<option value="gspect, gspect2" <?php if($table == "gspect, gspect2") echo $select; ?> >G-SPECT</option>
<option value="gamma" <?php if($table == "gamma") echo $select; ?> >Gamma Camera</option>
</select>
</td>
<td>
<select name="critere">
<option value="" >-- Choisissez un critere --</option>
<?php while($row = mysql_fetch_field($sql))
{
echo '<option value='. $row -> name .'>';
echo ''. $row -> name .'';
echo '</option>';
}?>
</select>
</td><td><input type="submit" value="OK"/></td>
</tr>
</table>
</form>
<?php }
else{ ?>
<form method="post" action="">
<table cellpadding="0" cellspacing="0">
<tr>
<td></td>
<td>
<select name="table">
<option value="">-- Choisissez un type d'examen --</option>
<option value="fevg">FEVG</option>
<option value="gspect, gspect2">G-SPECT</option>
<option value="gamma">Gamma Camera</option>
</select>
</td>
<td><input type="submit" value="OK"/></td>
</tr>
</table>
</form>
<?php } ?>
Prob résolu avec ce code, mais je n'arrive toujours pas a comprendre pourquoi il ne fonctionnait pas avant.
J'ai refait pas à pas la procédure et cela a marché. Si ca vous dit de regarder ....