我的代码存在问题。实际上,它应该显示表的信息,其中MomentEvent值与请求的行匹配。唯一的问题是,它有时会显示完整不同行的信息!我不知道为什么!问题来自我的代码吗?
在我的表格中,信息按顺序排列,因此它们总是一个接一个地添加。
<?php
include('base.php');
?>
<?php
if(isset($_GET['MomentEvent']))
{
$MomentEvent = intval($_GET['MomentEvent']);
$dn = mysql_query("select Ordre, Confidentialite, ID, TitreEvent, DescriptionEvent, LieuEvent from users_event where MomentEvent=$MomentEvent");
if(mysql_num_rows($dn)>0)
{
$dnn = mysql_fetch_array($dn);
?>
This is the profile of "<?php echo htmlentities($dnn['TitreEvent']); ?>" :
<table style="width:500px;">
<tr><td>
<?php
if($dnn['avatar']!='')
{
echo '<img src="'.htmlentities($dnn['avatar'], ENT_QUOTES, 'UTF-8').'" alt="Avatar" style="max-width:100px;max-height:100px;" />';
}
else
{
echo 'This user dont have an avatar.';
}
?>
</td>
<td class="left"><h1><?php echo ($dnn['TitreEvent']); ?></h1>
Email: <?php echo htmlentities($dnn['DescriptionEvent']); ?><br />
<a href=*****.php>Retour.</a>
</tr>
</table>
<?php
}
else
{
echo 'Sorry, any event found';
}
}
else
{
echo 'The user ID is not defined.';
}
?>
</body>
</html>
答案 0 :(得分:0)
您的代码中遗漏了</td>
。
并使用不带括号的echo $dnn['TitreEvent'];
试试这个
<td class="left"><h1><?php echo $dnn['TitreEvent']; ?></h1>
Email: <?php echo htmlentities($dnn['DescriptionEvent']); ?><br />
<a href=*****.php>Retour.</a>
</td>
^^----you missed this
编辑:
我想你从sql返回了很多结果,你需要在查询中指定更多结果。
像那样 where MomentEvent=$MomentEvent AND user = $theUser
答案 1 :(得分:0)
现在一切正常,这些变化:
$MomentEvent = $_GET['MomentEvent'];
$sql = "select ID, TitreEvent, DescriptionEvent, LieuEvent from users_event where MomentEvent='$MomentEvent'";
$dn = mysql_query($sql);