SEVIZ Posted March 17, 2009 Share Posted March 17, 2009 I am using this code $result = mysql_query("SELECT * FROM tech WHERE ID='".$_POST['tech']."'") or die(mysql_error()); // Print out the contents of the entry while($row = mysql_fetch_array($result)){ $NAME = $row['NAME']; $ID = $row['ID']; $ALLOW = $row['ALLOW']; $LOCA = $row['LOCA']; $TEAM = $row['TEAM']; } All is fine but how can I make an if statement that if $NAME is Null display "No name"? Thanks for any help! Quote Link to comment https://forums.phpfreaks.com/topic/149754-if-statement/ Share on other sites More sharing options...
Lodius2000 Posted March 17, 2009 Share Posted March 17, 2009 if ($name = NULL){ $name = 'No Name'; } Quote Link to comment https://forums.phpfreaks.com/topic/149754-if-statement/#findComment-786373 Share on other sites More sharing options...
.josh Posted March 17, 2009 Share Posted March 17, 2009 $NAME = ($row['NAME'] == '' || $row['NAME'] == false || is_null($row['NAME']) ? 'No name' : $row['Name']; Better thing to do would be to make 'No name' the default value in your database. Quote Link to comment https://forums.phpfreaks.com/topic/149754-if-statement/#findComment-786374 Share on other sites More sharing options...
Lodius2000 Posted March 17, 2009 Share Posted March 17, 2009 indeed Quote Link to comment https://forums.phpfreaks.com/topic/149754-if-statement/#findComment-786378 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.