Hi there, My code: include 'database_connect.php'; $query="SELECT * FROM auctions WHERE status = 'Payment Received'"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); $i=0; while ($i < $num) { include 'view_layout.php; PHP: I would like to know how I can echo "No items where payment is received." when there are no table entries WHERE status ='Payment Received' Any help would be appreciated. Thanks
Try this, if you want to not exit the script straight after then you will need to add a else{} after then and of that if statement, I cant show that as that code seems to be incomplete include 'database_connect.php'; $query="SELECT * FROM auctions WHERE status = 'Payment Received'"; $result=mysql_query($query); $num=mysql_numrows($result); if($num==0){ echo "No items where payment is received."; exit(); } mysql_close(); $i=0; while ($i < $num) { include 'view_layout.php; PHP:
<?php include 'database_connect.php'; $query="SELECT * FROM auctions WHERE status = 'Payment Received'"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); if($num<1) { echo "No items where payment is received."; } else { $i=0; while ($i < $num) { include "view_layout.php"; // mby $i++? } } ?> PHP: