كيف أتحقق من قيمة حقل فارغه باستخدام sql داخل صفحة php
$is=mysql_query("SELECT * from student WHERE name="" ")حيث أن name هو حقل أريد التحقق من أن قيمته فارغه
كيف أتحقق من قيمة حقل فارغه باستخدام sql داخل صفحة php
$is=mysql_query("SELECT * from student WHERE name="" ")حيث أن name هو حقل أريد التحقق من أن قيمته فارغه
$is=mysql_query("SELECT * from student WHERE name="" ");
$value = mysql_num_rows($is);
if ($value > 0) {echo 'field is empty';}else {echo 'field is not empty';}اولا يفضل ان يكون حقل name مفعل بخاصية null وهذا افضل عند كتابة جملة select في mysql
$is=mysql_query("SELECT * from student WHERE name=null ");count
لحساب عدد الصفوف الناتجة من الاستعلام السابق حيث عدد الصفوف الناتجة في المتغيير count
$count = mysql_num_rows($is);
نقوم بكتابة الجملة الشرطية لاعطاءنا الناتج
if ($count > 0)
{
echo “ empty !!!!”;
}
else
{
echo “not empty !!!”;
}If your actions inspire others to dream more, learn more, do more and become more, you are a leader
Best Regards
Feras Abualrub
استخدم is null
مثال
SELECT LastName,FirstName,Address FROM Persons WHERE Address IS NULL