?
Solved

Put text inside the php code

Posted on 2011-03-04
4
Medium Priority
?
338 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 7

Assisted Solution

by:Vimal DM
Vimal DM earned 664 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 668 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 668 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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.
Suggested Courses

764 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