Pas de récuppération d'information dans la base de donnée
Posté : 10 janv. 2016, 03:01
Bonjour, j'ai créer un script php pour un forum, mais il ne sélectionne pas les informations dans la base de donnée, quelqu'un pourrait m'aider ? Voici le script:
<?php
include('include/forum_config.php');
if(isset($_GET['parent']))
{
$id = intval($_GET['parent']);
$dn1 = mysql_fetch_array(mysql_query('select count(c.id) as nb1, c.name,count(t.id) as topics from categories as c left join topics as t on t.parent="'.$id.'" where c.id="'.$id.'" group by c.id'));
if($dn1['nb1']>0)
{
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php echo htmlentities($dn1['name'], ENT_QUOTES, 'UTF-8'); ?> - Forum</title>
</head>
<body>
<section id="main" class="wrapper">
<div class="container">
<header class="major">
<h2>Forum</h2>
</header>
<div class="content">
<?php
if(isset($_SESSION['username']))
{
$nb_new_pm = mysql_fetch_array(mysql_query('select count(*) as nb_new_pm from pm where ((user1="'.$_SESSION['userid'].'" and user1read="no") or (user2="'.$_SESSION['userid'].'" and user2read="no")) and id2="1"'));
$nb_new_pm = $nb_new_pm['nb_new_pm'];
?>
<h3><a href="forum_index.php">Index du forum</a> > <a href="forum_list_topics.php?parent=<?php echo $id; ?>"><?php echo htmlentities($dn1['name'], ENT_QUOTES, 'UTF-8'); ?></a></h3>
<?php
}
else
{
?>
<div class="box">
<div class="box_left">
<h3><a href="forum_index.php">Index du forum</a> > </h3><a href="forum_list_topics.php?parent=<?php echo $id; ?>"><?php echo htmlentities($dn1['name'], ENT_QUOTES, 'UTF-8'); ?></a>
</div>
<?php
}
if(isset($_SESSION['username']))
{
?>
<a href="forum_new_topic.php?parent=<?php echo $id; ?>" class="button">Nouveau Sujet</a>
<?php
}
$dn2 = mysql_query('select t.id, t.title, t.authorid, u.username as author, count(r.id) as replies from topics as t left join topics as r on r.parent="'.$id.'" and r.id=t.id and r.id2!=1 left join users as u on u.id=t.authorid where t.parent="'.$id.'" and t.id2=1 group by t.id order by t.timestamp2 desc');
if(mysql_num_rows($dn2)>0)
{
?>
<table class="topics_table">
<tr>
<th width="75%" style="text-align:center;">Sujet</th>
<th width="20%" style="text-align:center;">Auteur</th>
<th width="5%" style="text-align:center;">Réponses</th>
<?php
if(isset($_SESSION['username']) and $_SESSION['username']==$admin)
{
?>
<th width="10%" style="text-align:center;">Action</th>
<?php
}
?>
</tr>
<?php
while($dnn2 = mysql_fetch_array($dn2))
{
?>
<tr>
<td align="center"><a href="forum_read_topic.php?id=<?php echo $dnn2['id']; ?>"><?php echo htmlentities($dnn2['title'], ENT_QUOTES, 'UTF-8'); ?></a></td>
<td align="center"><a href="profile.php?id=<?php echo $dnn2['authorid']; ?>"><?php echo htmlentities($dnn2['author'], ENT_QUOTES, 'UTF-8'); ?></a></td>
<td align="center"><?php echo $dnn2['replies']; ?></td>
<?php
if(isset($_SESSION['username']) and $_SESSION['username']==$admin)
{
?>
<td align="center"><a href="forum_delete_topic.php?id=<?php echo $dnn2['id']; ?>"><img src="<?php echo $design; ?>/images/delete.png" alt="Supprimer" /></a></td>
<?php
}
?>
</tr>
<?php
}
?>
</table>
<?php
}
else
{
?>
<div class="message">Cette catégorie ne contient aucun sujet.</div>
<?php
}
if(isset($_SESSION['username']))
{
?>
<a href="forum_new_topic.php?parent=<?php echo $id; ?>" class="button">Nouveau Sujet</a>
<?php
}
else
{
?>
<?php
}
?>