Only show link if conditional equals true

Posted by Dave Morin on Stack Overflow See other posts from Stack Overflow or by Dave Morin
Published on 2012-06-29T12:28:21Z Indexed on 2012/06/29 15:16 UTC
Read the original article Hit count: 186

Filed under:
|

I want the link to appear only when $data['block'] equals to 1, 3 or 4. Not if it equals to 2 or 5.

<td style="font-size:18px;color:#f0cb01;">
    <a href="kickcodes.php?id='.$data["block"].'">Reason Codes</a>
</td>

EDIT

while ($data = mysql_fetch_array($query)) {

echo '
<tr style="background-color:#576c11;">
    <td style="font-size:18px; color:#f0cb01;">'.$data["keyword"].'</td>
    <td style="font-size:18px;color:#f0cb01;">'.$data["block"].'</td>
    <td style="font-size:18px;color:#f0cb01;">'.$data["phone"].'</td>
    <td style="font-size:18px;color:#f0cb01;">'.$data["Reason"].'</td>
    <td style="font-size:18px;color:#f0cb01;"><a href="kickcodes.php?id='.$data  ["block"].'">Kickcodes</a></td>'

    echo '<td style="font-size:18px;color:#f0cb01;">'; 
if( $data['block'] == 1 || $data['block'] == 3 || $data['block'] == 4)  
{ 
echo '<a href="kickcodes.php?id='.$data["block"].'">Reason Codes</a>'; 
} else  
{ 
echo '<span>Reason Codes</span>'; // Or echo nothing 
} 
echo '</td>'; 

© Stack Overflow or respective owner

Related posts about php

Related posts about if-statement