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! 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'; } 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. 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 Link to comment https://forums.phpfreaks.com/topic/149754-if-statement/#findComment-786378 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.