Tips, Trick, Mengatasi Masalah Komputer, Membina Website & Programming

PHP Code : Identify Empty Record / Kenal pasti Rekod Kosong


<?php 
require_once('connect.php');

mysql_select_db($database_connect, $connect);
$query_record = "SELECT * FROM tablename";
$record = mysql_query($query_record, $connect) or die(mysql_error());
$row_record = mysql_fetch_assoc($record);
$totalRows_record = mysql_num_rows($record);

?>

//Display Data
<?php 
if($totalRows_record==NULL)
{
   echo "Tiada Rekod";
}
else
{
   echo $row_record['fieldname'];
}
?>

0 comments: