arunpatal Posted November 15, 2012 Share Posted November 15, 2012 Hi I want if value exists for $codes3 then it shows div and if not then there is no div...... How can i do that???? <br /> <div id="codedisplay_box" style="overflow: auto;"> <code><xmp><?php echo $codes3; ?></xmp></code></div> <br /> Quote Link to comment https://forums.phpfreaks.com/topic/270725-if-value-exists/ Share on other sites More sharing options...
MDCode Posted November 15, 2012 Share Posted November 15, 2012 (edited) <?php if(isset($codes3)) { // execture that it does have a value } else { // It does not have a value } ?> Edited November 15, 2012 by SocialCloud Quote Link to comment https://forums.phpfreaks.com/topic/270725-if-value-exists/#findComment-1392605 Share on other sites More sharing options...
arunpatal Posted November 15, 2012 Author Share Posted November 15, 2012 (edited) <?php if(isset($codes3)) { // execture that it does have a value } else { // It does not have a value } ?> I am new so can you please write this code include with my code... I tried like this <?php if(isset($codes3)) { '<div id="detaildisplay_box"> echo $code3; </div>' ; } else { '<div id="detaildisplay_box"> echo "No Value!" </div>'; } ?> But its not working Edited November 15, 2012 by arunpatal Quote Link to comment https://forums.phpfreaks.com/topic/270725-if-value-exists/#findComment-1392610 Share on other sites More sharing options...
MDCode Posted November 15, 2012 Share Posted November 15, 2012 (edited) Sigh...It's not hard at all. In fact I shouldn't really even do it if you don't even know the echo function. I suggest going http://www.w3schools...php/default.asp for a good start. But I suppose I'll help anyways: <?php if(isset($codes3)) { echo " <br /> <div id='codedisplay_box' style='overflow: auto;'><code><xmp> $codes3</xmp></code></div> <br />"; } ?> Edited November 15, 2012 by SocialCloud Quote Link to comment https://forums.phpfreaks.com/topic/270725-if-value-exists/#findComment-1392611 Share on other sites More sharing options...
arunpatal Posted November 15, 2012 Author Share Posted November 15, 2012 (edited) Sigh...It's not hard at all. In fact I shouldn't really even do it if you don't even know the echo function. I suggest going http://www.w3schools...php/default.asp for a good start. But I suppose I'll help anyways: <?php if(isset($codes3)) { echo " <br /> <div id='codedisplay_box' style='overflow: auto;'><code><xmp> $codes3</xmp></code></div> <br />"; } ?> Thanks for help (it just work nice) Can you check if this also should be fine <?php if(isset($codes3)) { '<div id="detaildisplay_box"> echo $code3; </div>' ; } else { '<div id="detaildisplay_box"> echo "No Value!" </div>'; } ?> Edited November 15, 2012 by arunpatal Quote Link to comment https://forums.phpfreaks.com/topic/270725-if-value-exists/#findComment-1392612 Share on other sites More sharing options...
MDCode Posted November 15, 2012 Share Posted November 15, 2012 You can not put html inside of php tags. Use echo before html because right now you should be getting syntax errors Quote Link to comment https://forums.phpfreaks.com/topic/270725-if-value-exists/#findComment-1392613 Share on other sites More sharing options...
arunpatal Posted November 15, 2012 Author Share Posted November 15, 2012 You can not put html inside of php tags. Use echo before html because right now you should be getting syntax errors OK now i understand................ Thanks alot Quote Link to comment https://forums.phpfreaks.com/topic/270725-if-value-exists/#findComment-1392614 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.