显示基于sql查询的通知

时间:2015-08-11 21:55:19

标签: php mysql

我试图显示通知是用户在表格列中的值为“否则”#34;付费"。看起来一切对我来说都是对的...它只是不起作用。我究竟做错了什么。 (没有错误,只是没有显示通知。是的,我知道我应该使用mysqli)

<!--Start Unpaid Notification-->
<?php

$unpaid_user = $_SESSION['loggedInUser'];

$get_unpaid = mysql_query("SELECT * FROM nflp_users WHERE userID = '$unpaid_user' AND paid = 'NO'")or die(mysql_error());


//Display Notification
while($row = mysql_fetch_assoc($get_unpaid)) {
if($row['paid'] == 'NO') {
echo '<div class="pm_notification">You have not paid yet. Please click <a href="https://paypal.com/">here</a> to pay.</div>';
echo '<br>';
 }
}
?>
<!--End Unpaid Notification-->

1 个答案:

答案 0 :(得分:0)

我使用了错误的SQL查询。我需要查询*列,而不是使用paid查询所有列。

<!--Start Unpaid Notification-->
<?php

$unpaid_user = $_SESSION['loggedInUser'];

$get_unpaid = mysql_query("SELECT paid FROM nflp_users WHERE userID = '$unpaid_user'")or die(mysql_error());

//Display Notification
while($row = mysql_fetch_assoc($get_unpaid)) {
if($row['paid'] == 'NO') {
echo '<div class="pm_notification">You have not paid yet. Please click <a href="https://paypal.com/">here</a> to pay.</div>';
echo '<br>';
 }
}
?>
<!--End Unpaid Notification-->