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

PHP Code : Identify NULL Field / Kenal pasti field 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($row_record['fieldname']==NULL)
{
   echo "Field Name Kosong";
}
else
{
   echo $row_record['fieldname'];
}
?>

0 comments:

Blogger templates