Solved

Put text inside the php code

Posted on 2011-03-04
4
330 Views
Last Modified: 2012-05-11
I am calling info from a database.  An email address is displayed as:

Email: <?php echo $row_Recordset1['email']; ?>

However, if there isn't an email address for this particular entry the Email: is diplayed.

What I want to do is put the text 'Email:' inside the code so if there is no entry nothing shows on the live page.

Thanks in advance!
0
Comment
Question by:BrighteyesDesign
4 Comments
 
LVL 7

Assisted Solution

by:Vimal DM
Vimal DM earned 166 total points
ID: 35034777
Hai BrighteyesDesign,

It is very simple write  common function as below

function check_empty_put_($string){
    if(empty($string))
      return 'no email id';
}


like this you can make different type of displays (text,image,symbols,etc...)
0
 
LVL 27

Accepted Solution

by:
Lukasz Chmielewski earned 167 total points
ID: 35034783
if(!empty($row_Recordset1['email']))
echo"Email ".$row_Recordset1['email'];
0
 
LVL 39

Assisted Solution

by:Pratima Pharande
Pratima Pharande earned 167 total points
ID: 35034794
try this

Email: <?php echo strlen($row_Recordset1['email']) == 0 ? 'email' : $row_Recordset1['email'] ; ?>
0
 

Author Closing Comment

by:BrighteyesDesign
ID: 35034852
Thanks all!
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Creating Image Thumbnails Using PHP 3 16
Wordpress Body Class 5 13
Help cleaning out CSS 2 32
using hash in login 34 20
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now