Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Put text inside the php code

Posted on 2011-03-04
4
Medium Priority
?
339 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

598 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