probleme choix de valeur de classement
Dernière réponse : dans Programmation
Bonjour voila mon code qui a un problème entre les deux smileys.
Le nom est index2.php:
<table style="text-align: left; width: 20%;" border="1"
cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td style="height: 50%">
<form method="post" action="verif.php">
<p><label>Quel classement souhaitez-vous?
<select name="classe"
<option value="nom">Nom</option>
<option value="prix">Prix</option>
</select>
</label>
</p>
</form>
</td>
</tr>
</tbody>
</table>
<?
include("verif.php");
?>
<table style="text-align: center; color: rgb(255, 204, 51); font-weight: bold; background-color: rgb(153, 0, 0); width: 50%;"
border="1" cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td style="width: 75%;">Nom</td>
<td style="width: 25%;">Prix</td>
</tr>
</tbody>
</table>
<?php mysql_connect("localhost", "...", "..."); // Connexion à MySQL
mysql_select_db("jeux_videos"); // Sélection de la base jeux_videos
// Sélectionnons les champs nom et prix de la table "jeux_videos"
$reponse = mysql_query("SELECT nom, prix FROM jeux_videos ORDER BY ($classement)");
:-x while ($donnees = mysql_fetch_array($reponse) ) :-x
{
?>
<table style="text-align: center; width: 50%;" border="1"
cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td style="width: 75%;"><?php echo $donnees['nom']; ?></td>
<td style="width: 25%; color: rgb(255, 102, 0);"><b><?php echo $donnees['prix']; ?>€</b></td>
</tr>
</tbody>
</table>
<?php }
mysql_close(); // Déconnexion de MySQL
?>
celui de verif.php:
<?php
$classement = $_POST['classe'];
?>
Le nom est index2.php:
<table style="text-align: left; width: 20%;" border="1"
cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td style="height: 50%">
<form method="post" action="verif.php">
<p><label>Quel classement souhaitez-vous?
<select name="classe"
<option value="nom">Nom</option>
<option value="prix">Prix</option>
</select>
</label>
</p>
</form>
</td>
</tr>
</tbody>
</table>
<?
include("verif.php");
?>
<table style="text-align: center; color: rgb(255, 204, 51); font-weight: bold; background-color: rgb(153, 0, 0); width: 50%;"
border="1" cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td style="width: 75%;">Nom</td>
<td style="width: 25%;">Prix</td>
</tr>
</tbody>
</table>
<?php mysql_connect("localhost", "...", "..."); // Connexion à MySQL
mysql_select_db("jeux_videos"); // Sélection de la base jeux_videos
// Sélectionnons les champs nom et prix de la table "jeux_videos"
$reponse = mysql_query("SELECT nom, prix FROM jeux_videos ORDER BY ($classement)");
:-x while ($donnees = mysql_fetch_array($reponse) ) :-x
{
?>
<table style="text-align: center; width: 50%;" border="1"
cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td style="width: 75%;"><?php echo $donnees['nom']; ?></td>
<td style="width: 25%; color: rgb(255, 102, 0);"><b><?php echo $donnees['prix']; ?>€</b></td>
</tr>
</tbody>
</table>
<?php }
mysql_close(); // Déconnexion de MySQL
?>
celui de verif.php:
<?php
$classement = $_POST['classe'];
?>
Autres pages sur : probleme choix valeur classement
Lassé par la pub ? Créez un compte
mysql_connect("localhost", "identifiant", "mot de passe"); // Connexion à MySQL
mysql_select_db("nom de la base"); // Sélection de la base jeux_videos
// Sélectionnons les champs nom et prix de la table "jeux_videos"
$reponse = mysql_query("SELECT nom, prix FROM jeux_videos ORDER BY $classement") or die ('Erreur :<br>'.mysql_error());
while ($donnees = mysql_fetch_array($reponse))
{
essaie, ça devrait marcher je pense, sinon autre chose, là tu vas créer un tableau pour chaque fiche sortie, ne serait-il pas plus judicieux de ne créer qu'une ligne d'un même tableau à chaque fois ?
mysql_select_db("nom de la base"); // Sélection de la base jeux_videos
// Sélectionnons les champs nom et prix de la table "jeux_videos"
$reponse = mysql_query("SELECT nom, prix FROM jeux_videos ORDER BY $classement") or die ('Erreur :<br>'.mysql_error());
while ($donnees = mysql_fetch_array($reponse))
{
essaie, ça devrait marcher je pense, sinon autre chose, là tu vas créer un tableau pour chaque fiche sortie, ne serait-il pas plus judicieux de ne créer qu'une ligne d'un même tableau à chaque fois ?
Je te redonne le script modifier
<table style="text-align: left; width: 20%;" border="1"
cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td style="height: 50%">
<form method="post" action="verif.php">
<p><label>Quel classement souhaitez-vous?
<select name="classe"
<option value="nom">Nom</option>
<option value="prix">Prix</option>
</select>
</label>
</p>
</form>
</td>
</tr>
</tbody>
</table>
<?
include("verif.php");
?>
<table style="text-align: center; color: rgb(255, 204, 51); font-weight: bold; background-color: rgb(153, 0, 0); width: 50%;"
border="1" cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td style="width: 75%;">Nom</td>
<td style="width: 25%;">Prix</td>
</tr>
</tbody>
</table>
<?php mysql_connect("localhost", "....", "....."); // Connexion à MySQL
mysql_select_db("jeux_videos"); // Sélection de la base jeux_videos
// Sélectionnons les champs nom et prix de la table "jeux_videos"
$reponse = mysql_query("SELECT nom, prix FROM jeux_videos ORDER BY $classement") or die ('Erreur :<br>'.mysql_error());
while ($donnees = mysql_fetch_array($reponse))
{
?>
<table style="text-align: center; width: 50%;" border="1"
cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td style="width: 75%;"><?php echo $donnees['nom']; ?></td>
<td style="width: 25%; color: rgb(255, 102, 0);"><b><?php echo $donnees['prix']; ?>€</b></td>
</tr>
</tbody>
</table>
<?php }
mysql_close(); // Déconnexion de MySQL
?>
et le verif.php:
<?php
if (isset($_POST['classe']))
{
$classement = $_POST['classe'];
}
else
{
$classement = "id";
}
?>
Mais je n'ai pas compris ton système mais ce n'est pas grave.
Le nouveau problème est que ce n'est pas classé par prix ou par nom mais dans le désordre.
<table style="text-align: left; width: 20%;" border="1"
cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td style="height: 50%">
<form method="post" action="verif.php">
<p><label>Quel classement souhaitez-vous?
<select name="classe"
<option value="nom">Nom</option>
<option value="prix">Prix</option>
</select>
</label>
</p>
</form>
</td>
</tr>
</tbody>
</table>
<?
include("verif.php");
?>
<table style="text-align: center; color: rgb(255, 204, 51); font-weight: bold; background-color: rgb(153, 0, 0); width: 50%;"
border="1" cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td style="width: 75%;">Nom</td>
<td style="width: 25%;">Prix</td>
</tr>
</tbody>
</table>
<?php mysql_connect("localhost", "....", "....."); // Connexion à MySQL
mysql_select_db("jeux_videos"); // Sélection de la base jeux_videos
// Sélectionnons les champs nom et prix de la table "jeux_videos"
$reponse = mysql_query("SELECT nom, prix FROM jeux_videos ORDER BY $classement") or die ('Erreur :<br>'.mysql_error());
while ($donnees = mysql_fetch_array($reponse))
{
?>
<table style="text-align: center; width: 50%;" border="1"
cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td style="width: 75%;"><?php echo $donnees['nom']; ?></td>
<td style="width: 25%; color: rgb(255, 102, 0);"><b><?php echo $donnees['prix']; ?>€</b></td>
</tr>
</tbody>
</table>
<?php }
mysql_close(); // Déconnexion de MySQL
?>
et le verif.php:
<?php
if (isset($_POST['classe']))
{
$classement = $_POST['classe'];
}
else
{
$classement = "id";
}
?>
Mais je n'ai pas compris ton système mais ce n'est pas grave.
Le nouveau problème est que ce n'est pas classé par prix ou par nom mais dans le désordre.
Lassé par la pub ? Créez un compte
- Contenus similaires :
- SolutionsChoix classe heal wow
- ForumProblème de choix alim PC
- ForumProblème de choix de boot
- SolutionsProblem excel: #VALEUR!
- ForumProblème avec iTunes pour le classement des musiques
- ForumProblème avec trouver une valeur dans un petit tableau excel
- SolutionsProblème iPod Classis 80 Go .
- Forumproblème de choix de barette mémoire
- ForumChoix de pc portable, problème carte graphique
- Voir plus