مرجع تخصصی برنامه نویسان

انجمن تخصصی برنامه نویسان فارسی زبان

کاربر سایت

hediyeh-71

عضویت از 1394/07/26

اجرا نشدن شرط if

  • شنبه 13 شهریور 1395
  • 19:31
تشکر میکنم
سلام دوستان 

من میخوام شرط سوم اجرا شه ولی نمیشه 

؟؟؟

ممنون

<?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>';


	
	}



?>

 

پاسخ های این پرسش

تعداد پاسخ ها : 1 پاسخ
کاربر سایت

mywc

عضویت از 1395/09/05

  • جمعه 5 آذر 1395
  • 23:31

از elseif استفاده کن

کاربرانی که از این پست تشکر کرده اند

هیچ کاربری تا کنون از این پست تشکر نکرده است

اگر نیاز به یک مشاور در زمینه طراحی سایت ، برنامه نویسی و بازاریابی الکترونیکی دارید

با ما تماس بگیرید تا در این مسیر همراهتان باشیم :)