par
Seb K » 26 oct. 2015, 19:51
Bonsoir,
Je reviens par ici car après une journée de recherche infructueuse j'ai pas vraiment avancé ...
il me semble que dans mon code (pas très propre) il y'ai quelques erreurs de syntaxe qui font que je n'arrive pas à afficher ma liste déroulante. Aussi les tests que je fais sur ma variable $_POST indiquent qu'elle est vide. Outre les message de type :
Notice: Undefined index: topic_tag_name in /var/www/html/forum_ap/test_mod/form_tab_topics2.php on line 15
Mon code :
<?php
$db = new PDO('mysql:host=localhost;dbname=zapilouforada;charset=utf8', 'root', 'rootadmin');
$sql = 'SELECT t1.forum_id as id1,t1.forum_name as nom1, t2.forum_id as id2, t2.forum_name as nom2, t3.topic_id, t3.topic_title, t3.post_tag
FROM phpbb_forums t1 left join phpbb_forums t2 on t2.parent_id = t1.forum_id left join phpbb_topics t3 on t2.forum_id = t3.forum_id
WHERE t1.parent_id = 141 ORDER BY t3.post_tag DESC';
$cat = $db->query("SELECT * FROM phpbb_topics_tag");
while ($data = $cat->fetch())
{
$data['topic_tag_id'];
$data['topic_tag_name'];
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Tableau des Topics</title>
</head>
<body>
<h3>Tableau des TOPICS</h3>
<form action="toto.php" method="post">
<?php
$tmp = $db->query($sql);
echo '<table border=2>
<thead>
<th>ID</th>
<th>Topics</th>
<th>Mot Clé</th>
<th>Envoyer</th>
<th>Mots clés</th>
</thead>';
while($topic = $tmp->fetch())
{
echo '<tr><td><input type="text" name="topic_id" id="topic_id" value="'.$topic['topic_id'].'"></td><td>' //zone type input qui doit être implémentée
.$topic['topic_title'].'</td><td>
<select name="topic_tag_id" id="topic_tag_id"><option value="'.$data['topic_tag_name'].'">Sélectionnez un mot clé...</option>
<option value="'.$data['topic_tag_id'].'">'.$data['topic_tag_name'].'</option>
</select></td><td>
<input type="submit"/></td> <td>' //bouton qui envoie le $_POST contenant 'topic_tag_id' et 'topic_id
.$topic['post_tag'].'</td></tr>'; //créer un array qui m'affiche les mots clés associés sous forme de lien href qui supprime le mot clé
}
echo '</tbody></table>';
?>
</body>
</html>
Variable $_POST :
Array ( [topic_id] => [topic_tag_id] =>
Je pense que mes variables ne sont pas correctement initialisée mais je ne sais plus ou chercher ...
Merci d'avance
Bonsoir,
Je reviens par ici car après une journée de recherche infructueuse j'ai pas vraiment avancé ...
il me semble que dans mon code (pas très propre) il y'ai quelques erreurs de syntaxe qui font que je n'arrive pas à afficher ma liste déroulante. Aussi les tests que je fais sur ma variable $_POST indiquent qu'elle est vide. Outre les message de type : [html]Notice: Undefined index: topic_tag_name in /var/www/html/forum_ap/test_mod/form_tab_topics2.php on line 15[/html]
[u][b]Mon code : [/b][/u]
[php]<?php
$db = new PDO('mysql:host=localhost;dbname=zapilouforada;charset=utf8', 'root', 'rootadmin');
$sql = 'SELECT t1.forum_id as id1,t1.forum_name as nom1, t2.forum_id as id2, t2.forum_name as nom2, t3.topic_id, t3.topic_title, t3.post_tag
FROM phpbb_forums t1 left join phpbb_forums t2 on t2.parent_id = t1.forum_id left join phpbb_topics t3 on t2.forum_id = t3.forum_id
WHERE t1.parent_id = 141 ORDER BY t3.post_tag DESC';
$cat = $db->query("SELECT * FROM phpbb_topics_tag");
while ($data = $cat->fetch())
{
$data['topic_tag_id'];
$data['topic_tag_name'];
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Tableau des Topics</title>
</head>
<body>
<h3>Tableau des TOPICS</h3>
<form action="toto.php" method="post">
<?php
$tmp = $db->query($sql);
echo '<table border=2>
<thead>
<th>ID</th>
<th>Topics</th>
<th>Mot Clé</th>
<th>Envoyer</th>
<th>Mots clés</th>
</thead>';
while($topic = $tmp->fetch())
{
echo '<tr><td><input type="text" name="topic_id" id="topic_id" value="'.$topic['topic_id'].'"></td><td>' //zone type input qui doit être implémentée
.$topic['topic_title'].'</td><td>
<select name="topic_tag_id" id="topic_tag_id"><option value="'.$data['topic_tag_name'].'">Sélectionnez un mot clé...</option>
<option value="'.$data['topic_tag_id'].'">'.$data['topic_tag_name'].'</option>
</select></td><td>
<input type="submit"/></td> <td>' //bouton qui envoie le $_POST contenant 'topic_tag_id' et 'topic_id
.$topic['post_tag'].'</td></tr>'; //créer un array qui m'affiche les mots clés associés sous forme de lien href qui supprime le mot clé
}
echo '</tbody></table>';
?>
</body>
</html>[/php]
[b][u]Variable $_POST :[/u][/b]
[php]Array ( [topic_id] => [topic_tag_id] =>[/php]
Je pense que mes variables ne sont pas correctement initialisée mais je ne sais plus ou chercher ...
Merci d'avance