我对下面的代码有问题。事实上,它应该显示一个表的信息,其中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>
您的代码中遗漏了</td>
。
并使用不带括号的CCD_ 2
试试这个
<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
现在所有这些更改都可以正常工作:
$MomentEvent = $_GET['MomentEvent'];
$sql = "select ID, TitreEvent, DescriptionEvent, LieuEvent from users_event where MomentEvent='$MomentEvent'";
$dn = mysql_query($sql);