blueearth Posted March 9, 2009 Share Posted March 9, 2009 I am new to php but loving it. How would I hide the title "phone:" on the following page if there is no phone number entered in the database for that contact? http://dynamichomes.com.previewdns.com/builderlocator/builderresult.php?id=1 I thank you all in advance! Link to comment https://forums.phpfreaks.com/topic/148658-how-to-hid-a-title-if-the-field-is-empty/ Share on other sites More sharing options...
redarrow Posted March 9, 2009 Share Posted March 9, 2009 something to digest. ((try it out, work it out as your learning. <?php // database connection. //select a phone number where the id = whatever. $sql="SELECT phone FROM what_ever where id='$what_ever'"; // get the select sql statement. $res=mysql_query($sql)or die("You got a $sql error".mysql_error()); //fetch a array of $row to get the phone number. $row=mysql-fetch_array($res); // put $row array name as variable $phone. $phone=$row['phone']; // if the variable name $phone is empty. if(empty($phone)){ // if empty set variable $phone to this comment. $phone="your phone number is not set"; }else{ // else if there is a number show this comment. $phone= " your phone number is : $phone"; } // echo out the variable of $phone. echo $phone; ?> Link to comment https://forums.phpfreaks.com/topic/148658-how-to-hid-a-title-if-the-field-is-empty/#findComment-780628 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.