Solved

Put text inside the php code

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

839 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