Solved

Put text inside the php code

Posted on 2011-03-04
4
335 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 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

724 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