Click here to Skip to main content
15,905,233 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hi there how do i only make this div show if there is a error
PHP
<div class="notice">
    <a href="" class="close">close</a>
    <p class="warn"><?php if ($login->errors) { foreach ($login->errors as $error) { echo $error; } } if ($login->messages) { foreach ($login->messages as $message) { echo $message; } } ?></p>
</div>

and how to close it using the close button i created
Posted
Updated 2-Jan-14 6:23am
v4

1 solution

You are doing it right, only move the generation (using echo) of your div and all its inner HTML code under the PHP block with if.
—SA
 
Share this answer
 
Comments
Abhinav S 2-Jan-14 12:59pm    
5!
Sergey Alexandrovich Kryukov 2-Jan-14 14:32pm    
Thank you, Abhinav.
—SA
Nico_Travassos 2-Jan-14 13:01pm    
Im not 100% sure what you mean and if i click close will the error close?
Sergey Alexandrovich Kryukov 2-Jan-14 14:31pm    
I mean your <php? .. ?>. You some code inside and outside of these brackets. Move all outside code inside, under if. This way, the whole thing, starting with the <div... > will appear under "if".
It is clear now?
—SA
Nico_Travassos 2-Jan-14 14:33pm    
Yes thank you thats much clear

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900