PDA

View Full Version : اجرا نشدن if



hediyeh-71
شنبه 13 شهریور 1395, 19:06 عصر
سلام دوستان
من میخوام شرط سوم اجرا شه که جفت صفر شدند پیغام محصول نیست بده ولی نمیشه
؟؟؟
ممنون


<?php


$sql="select * from tblmortabet where id1=? ";
$id=intval($_GET['id']);
$array=array($id);
$result=$object->select($sql,$array);


$num=$object->num($sql,$array);






if($num !=0 ){
foreach( $result as $row){

$id2=$row['id2'];
$sql="select * from tblmahsool where id=? ";
$array=array($id2);
$result2=$object->select($sql,$array);






echo '<a href="mahsool.php?id='.$id2.'" style="display:block; width:150px;height:160px; border:1px solid #9E9B9B;text-align:center; float:left; border-radius:6px; padding:16px; cursor:pointer; text-decoration:none;margin-right:10px;"> <img style="width:100%; height:125px;" src="'.$result2[0]['img'].'">
<span style="font-family:tahoma; font-size:14px;" >'.$result2[0]['title'].'</span>
</a>';
}


}








$sql="select * from tblmortabet where id2=? ";
$id=intval($_GET['id']);
$array=array($id);
$result=$object->select($sql,$array);


$num1=$object->num($sql,$array);

if($num1 !=0 ){
foreach( $result as $row){





$id1=$row['id1'];
$sql="select * from tblmahsool where id=? ";
$array=array($id1);
$result2=$object->select($sql,$array);



echo '<a href="mahsool.php?id='.$id1.'" style="display:block; width:150px;height:160px; border:1px solid #9E9B9B;text-align:center; float:left; border-radius:6px; padding:16px; cursor:pointer; text-decoration:none; margin-right:10px;padding-bottom: 15px;margin-bottom: 20px; margin-left: 11px; "> <img style="width:100%; height:125px; " src="'.$result2[0]['img'].'">
<span style="font-family:tahoma; font-size:14px;" >'.$result2[0]['title'].'</span>
</a>';



}








}//if




if($num==0 && $num1==0) {
echo '<p style=" font-family:tahoma; font-size:17; text-decoration:center; font-weight:bold; direction:rtl; text-align:center; padding:51px;"> محصولی یافت نشد.</p>';





}






?>

sara.ghavam
یک شنبه 14 شهریور 1395, 08:57 صبح
سلام دوست عزیز میشه واضحتر سوالت رو مطرح کنی؟

arash_fa
یک شنبه 14 شهریور 1395, 20:21 عصر
الان شرط درسته ولی ممکنه متغیر هایی که چگشون میکنی یک مقدار دیگه داخلشه که برابری با صفر میدی کار نده

اول var_dump کن ببین چی توشه اصلا

var_dump($mum);
var_dump($mum1);


اینو تست کنید


if(!$num && !$num1) { echo '<p style=" font-family:tahoma; font-size:17; text-decoration:center; font-weight:bold; direction:rtl; text-align:center; padding:51px;"> محصولی یافت نشد.</p>';




}

یا


if(((int)$num)==0 &&((int)$num1==0)) { echo '<p style=" font-family:tahoma; font-size:17; text-decoration:center; font-weight:bold; direction:rtl; text-align:center; padding:51px;"> محصولی یافت نشد.</p>';




}