我正在构建一个应用程序,让用户有机会点击日历的当天以及当天有活动注册时,它会显示一个表...我的问题是,当那天没有活动的时候,我不会让它返回字符串:没有活动..我尝试使用下面的if($nrofrows>0)
来使它变成如下形式,但总是返回字符串:there不是活动,即使我那天有活动。 请你帮帮我吗?我的错误在哪里?在此先感谢...当查询不返回结果在mysql中时显示错误
<body>
<?php
mysql_connect("127.0.0.1","root","") or die("Smund te lidhet me serverin");
mysql_select_db("axhenda") or die("Kjo databaze nuk u gjet");
session_start();
$perdoruesi=$_SESSION['user_id'];
$result= mysql_query("SELECT * FROM Aktiviteti where Data= '$_POST[dataoutput]' and Perd_Id='$perdoruesi'");
$nrofrows= mysql_num_rows($result);
if($nrofrows>0)
{
?>
<div class="title"> Aktivitetet per daten <?php print ("$_POST[dataoutput]"); ?></div>
<form name="form1" method="post" action="delete.php">
<table >
<th>
<th ><strong>Emri </strong></th>
<th ><strong>Pershkrimi </strong></th>
<th><strong>Ora</strong></th>
</th>
<?php
while ($row=mysql_fetch_array($result)) {
?>
<tr>
<td ><input name="checkbox[]" type="checkbox" value="<?php echo $row['Id_Akt']; ?>"></td>
<td style="font-size:0.9em"><?php echo $row['Emri']; ?></td>
<td ><?php echo $row['Pershkrimi']; ?></td>
<td><?php echo $row['Ora']; ?></td>
</tr>
<?php
}
?>
</table>
<input class="button" name="delete" type="submit" value="Delete" style="margin-left:40%; margin-top:100px; width:15%">
</form>
<?php
}
else {
echo "<span id='errorformat'>There is no activity on this day!<span>";}
?>
</body>
</html>
TR y查看你的查询,如下所示:'$ query =“SELECT * FROM Aktiviteti where Data ='$ _POST [dataoutput]'和Perd_Id ='$ perdoruesi'”;'然后在下面一行make'$ result = mysql_query( $ query);'然后在'$ query'被定义以查看您的变量的值是否正确分配后,添加'echo $ query;'行。 – Justice
谢谢,但我解决了它....我一直试图解决它整天,但现在我看到问题是当我打电话查询采取用户的名字...我把这部分关闭,现在它的功能。 – user3272713