Jump to content

[SOLVED] if statement help


twilitegxa

Recommended Posts

How can I add parentheses around my variable here?

 

while ($defects_info = mysql_fetch_array($get_defects_res)) {
$defects_id = $defects_info['id'];
$defects_identity = $defects_info['identity'];
$defects_id = $defects_info['defect_id'];
$desc = $defects_info['desc'];
$defects_level = $defects_info['level'];

if($desc == null){$GLOBALS['desc'] = "";}

$get_defects_names = "select * from defects where id = '$defects_id'";
$get_defects_names_res = mysql_query($get_defects_names, $conn) or die(mysql_error());

while ($defects_names_info = mysql_fetch_array($get_defects_names_res)) {
$defects_names_id = $defects_names_info['id'];
$defect = $defects_names_info['defect'];

$display_block .= "

<tr>
<td>$defect</td>
<td>$desc</td>
<td>$defects_level</td>
</tr>";

}
}

 

I want () around the $desc, but only if there is a value in the desc field. If there is no value, I want the entire cell blank. How can I do this? Right now i have it so that it displays the $desc if there is a value, or does not display is the field is blank. All I want to do now is add parentheses around the $desc. How can I do this?

Link to comment
https://forums.phpfreaks.com/topic/170733-solved-if-statement-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.