Les archives de FluxBB.fr
Vous n'êtes pas identifié(e).
Pages : 1
Bonjour.
J'ai un petit problème car, dans le panel d'admin, j'ai changer un peu le mod d'indications pour qu'il ait un rang. Ex: quand l'indication est rang 1, elle se mettra verte, rang 2 elle se mettra orange, etc...
Donc le code du panel d'admin :
if (isset($_POST['indication']) AND isset($_POST['rang_indication']))
{
// Make sure something something was entered
if (trim($_POST['indication']) == '')
message('Vous devez choisir un nom à l\'indication');
// AJout à la base
$indication = $_POST["indication"];
$rang = $_POST["rang_indication"];
$db->query('INSERT INTO '.$db->prefix.'indications VALUES ("", "'.$indication.'", "'.$rang.'")');
...
<table class="aligntop" cellspacing="0">
<tr>
<th scope="row">Indication<div><input name="ajouter" type="submit" id="ajouter" tabindex="2" value="Ajouter " />
</div>
</th>
<td><input name="indication" type="text" id="indication" tabindex="1" size="25" />
<span>L'indication que vous voulez ajouter. </span> </td>
</tr>
<td><input name="rang_indication" type="text" id="rang_indication" tabindex="1" size="25" />
<span>Le rang de l'indication que vous voulez ajouter. 1 pour bien, 2 pour neutre et 3 pour mauvais.</span> </td>
</tr>
</table>Donc là je met l'indication sur un sujet, puis je vais dans viewforum.php
Le code :
if ($cur_topic['indication'] != '0') {
$indication_id = $cur_topic['indication'];
$sqlb = 'SELECT text FROM '.$db->prefix.'indications WHERE id = "'.$indication_id.'"';
$resultb = $db->query($sqlb) or error('Imposible de trouver la table "indications"', __FILE__, __LINE__, $db->error());
$db->query('SELECT rang FROM '.$db->prefix.'indications WHERE id = "'.$indication_id.'"');
$line = $db->fetch_assoc($resultb);
$indication = $line['text'];
$is_indication = true;
...
if ($is_indication)
if ($rang_indication == 1)
{
echo '<strong style="color: green">'.$indication.'</strong>';
}
elseif ($rang_indication == 2)
{
echo '<strong style="color: #FF8C00">'.$indication.'</strong>';
}
elseif ($rang_indication == 3)
{
echo '<strong style="color: red">'.$indication.'</strong>';
}Resultat : je ne vois rien 
Ma question est simple, je dois mettre quel requète sql pour que ça marche, car j'en suis sûr à 99% que c'est ça qui plante...
Merci 
PS : ... remplace un bout de code inutile 
Hors ligne
salut,
je ne sais pas exactement ce qu'il faut que tu mette mais je pense qu'il faut que tu revois ton schéma parce que là tu fait tout un tas de requêtes pour juste une petite information, c'est très terrible
plutôt que créer une nouvelle table pour tes couleur tu devrait ajouter une colonne à la table rank qui contiendra l'info de couleur, ainsi quand tu récupère le rang de l'utilisateur tu récupère en même temps la couleur qui est associée au rang
Hors ligne
Je veux que l'indicatio se mette d'une couleur, pas le reste 
Bref je vais triffouillé là 
Hors ligne
bah ouais mais ça n'a rien à voir 
je ne parle pas du résultat final, je parle d'où est stockée l'information
créer une table pour stocker un chiffre à un numéro qui est lié a une information elle-même stockée dans une table c'est une erreur de conception ; et puis même si tu fait comme ça faire deux requêtes pour récupérer une seule information c'est une autre erreur de conception
mais bon tu fait comme tu veut hein 
Hors ligne
Resolu 
Code :
if ($cur_topic['indication'] != '0') {
$indication_id = $cur_topic['indication'];
$sqlb = 'SELECT * FROM '.$db->prefix.'indications WHERE id = "'.$indication_id.'"';
$resultb = $db->query($sqlb) or error('Imposible de trouver la table "indications"', __FILE__, __LINE__, $db->error());
$line = $db->fetch_assoc($resultb);
$indication = $line['text'];
$rang_indication = $line['rang'];
$is_indication = true;
}
else { $is_indication = false; }
?>
<tr<?php if ($item_status != '') echo ' class="'.trim($item_status).'"'; ?>>
<td class="tcl">
<div class="intd">
<div class="<?php echo $icon_type ?>"><div class="nosize"><?php echo trim($icon_text) ?></div></div>
<div class="tclcon">
<?php
if ($is_indication)
if ($rang_indication == 1)
{
echo '<strong style="color: green">'.$indication.'</strong> ';
}
elseif ($rang_indication == 2)
{
echo '<strong style="color: #FF8C00">'.$indication.'</strong> ';
}
elseif ($rang_indication == 3)
{
echo '<strong style="color: red">'.$indication.'</strong> ';
}
?>Merci pour ta participation vin100 
Tètre que je mettrais tout via MySQL 
Hors ligne
Pages : 1