DavvaM Posted November 22, 2022 Share Posted November 22, 2022 I am trying to show a header image on my home page. In the backend it is possible to select a checkbox for each news post and event post that will show a header image on the home page. At the moment if I select to show an event post image it still leaves the div space above for the news post image, so we need to hide his if an event image is selected and vice versa. Would this be possible with if/else statements? Below are the PHP functions <div class="col- big-news-here"> <?= $news2[0] ?> <?= $eventsHome[0] ?> </div> So basically, If news image is selected show the news div and banner If the events banner is selected show the events div and banner and hide news div. Many thanks Quote Link to comment https://forums.phpfreaks.com/topic/315572-ifelse-statements/ Share on other sites More sharing options...
requinix Posted November 22, 2022 Share Posted November 22, 2022 Probably? Consider that we have absolutely no idea who you are, what you're working with, or what kind of problem you're facing - except for what you tell us. Things like "news posts" and "header images" and "events banners" mean nothing to us unless you can describe what they are. Quote Link to comment https://forums.phpfreaks.com/topic/315572-ifelse-statements/#findComment-1602867 Share on other sites More sharing options...
ginerjm Posted November 22, 2022 Share Posted November 22, 2022 Actually - Below are NOT php functions. It is simply some sloppy php code. <div class="col- big-news-here"> <?= $news2[0] ?> <?= $eventsHome[0] ?> </div> Here is some better code: echo " <div class='col- big-news-here'> $news2[0] $eventsHome[0] </div> "; Of course if you want to format it a bit you can add some more html. Quote Link to comment https://forums.phpfreaks.com/topic/315572-ifelse-statements/#findComment-1602870 Share on other sites More sharing options...
Barand Posted November 22, 2022 Share Posted November 22, 2022 1 hour ago, ginerjm said: Here is some better code: It does exactly the same thing. Apart from making the PHP processor work a little harder, what does it achieve? Quote Link to comment https://forums.phpfreaks.com/topic/315572-ifelse-statements/#findComment-1602872 Share on other sites More sharing options...
ginerjm Posted November 22, 2022 Share Posted November 22, 2022 It is code that makes sense without having to switch gears to interpret it. Quote Link to comment https://forums.phpfreaks.com/topic/315572-ifelse-statements/#findComment-1602873 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.