twilitegxa Posted August 17, 2009 Share Posted August 17, 2009 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? Quote Link to comment Share on other sites More sharing options...
ldb358 Posted August 17, 2009 Share Posted August 17, 2009 if i understand your question i think should do it: if($defects_info['desc'] != ""){ $desc = "(" . $defects_info['desc'] . ")"; }else{ $desc = ""; } Quote Link to comment Share on other sites More sharing options...
twilitegxa Posted August 17, 2009 Author Share Posted August 17, 2009 Thank you, that did it perfectly! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.