채택완료

조건문 넣기 질문 드립니다.

2016-11-15 (화) 14:03:06 2,767

Copy
while($row = mysql_fetch_array($result)) {   $EXCEL_STR .= "   <tr>       <td>".$row['idx']."</td>         <td>".$row['aaa']."</td>         <td>".$row['bbb']."</td>  	 <td>".$row['ccc']."</td>     </tr>     ";}$EXCEL_STR .= "</table>";
 


이코드에 $row['aaa'] 대신 다음과 같은 조건문

 if($row['aaa'] == 이순신){

 echo '만세';

} else if($row['aaa'] == 박근혜){

 echo '하야하라'; 

}

를 넣고 싶은세, 어떻게 해야할까요?? 문법이 약해서 

잘 안되네요ㅠㅠ

|

답변 1개

채택된 답변
+20 포인트
2016-11-15 (화) 14:36:59

$text = "";

while($row = mysql_fetch_array($result)) {


if($row['aaa'] == 이순신){

 $text =  '만세';

} else if($row['aaa'] == 박근혜){

  $text =  '하야하라'; 

}

03   $EXCEL_STR .= "
04   <tr>
05       <td>".$row['idx']."</td>  
06       <td>".$text."</td>  
07       <td>".$row['bbb']."</td>  
08     <td>".$row['ccc']."</td>  
09   </tr>  
10   ";
11}

답변을 작성하려면 로그인이 필요합니다.