I have got a blog main page and the actual blog articles pages that are stored in a database table and uses a main blog index.php page where all the blog articles are displayed and then the individual blog articles are displayed on a page called viewpost.php and it gets the relevant blog article from the database using id/postSlug so the urls are SEO friendly and not something like id=1 and so on. I am looking to display some content that uses HTML coding on a specific blog article using php I thought I could do something like the following but does not display anything <? if($row['postSlug'] == 'fake-antivirus-software-scam') { ?> <div class="article"> <div class="text-center"> <div class="col-md-12"> <h3 class="h-lg text-center">Areas <span class="color">We</span> Cover</span></h3> </div> <div class="col-md-6"> <ul class="areaslist"> <li class="areasitem"><a href="computer-repair-basildon"><span>Basildon</span></a></li> <li class="areasitem"><a href="computer-repair-services-pitsea"><span>Pitsea</span></a></li> <li class="areasitem"><a href="computer-repair-laindon"><span>Laindon</span></a></li> </ul> </div> <div class="col-md-6"> <ul class="areaslist"> <li class="areasitem"><a href="computer-repair-langdon-hills"><span>Langdon Hills</span></a></li> <li class="areasitem"><a href="computer-repair-wickford"><span>Wickford</span></a></li> </ul> </div> </div> </div> <? } ?> Code (markup): I have tried the following as well but is not displaying nothing of what I want <?php if ($postID=="24") echo '<div class="article"> <div class="text-center"> <div class="col-md-12"> <h3 class="h-lg text-center">Areas <span class="color">We</span> Cover</span></h3> </div> <div class="col-md-6"> <ul class="areaslist"> <li class="areasitem"><a href="computer-repair-basildon"><span>Basildon</span></a></li> <li class="areasitem"><a href="computer-repair-services-pitsea"><span>Pitsea</span></a></li> <li class="areasitem"><a href="computer-repair-laindon"><span>Laindon</span></a></li> </ul> </div> <div class="col-md-6"> <ul class="areaslist"> <li class="areasitem"><a href="computer-repair-langdon-hills"><span>Langdon Hills</span></a></li> <li class="areasitem"><a href="computer-repair-wickford"><span>Wickford</span></a></li> </ul> </div> </div> </div>'; ?> Code (markup): I have tried to look on Google to find similar coding for what I am looking to do but not had much joy yet, can anyone help please. Thank you in advance
I have tried both of them ways and does not display the html list 'fake-antivirus-software-scam' is the postSlug of the blog article so the url is www.it-doneright.co.uk/blog/fake-antivirus-software-scam
I have just managed to solve it by using the following code <?php if($row['postID'] == '24') echo '<div class="article"> <div class="text-center"> <div class="col-md-12"> <h3 class="h-lg text-center">Areas <span class="color">We</span> Cover</span></h3> </div> <div class="col-md-6"> <ul class="areaslist"> <li class="areasitem"><a href="computer-repair-basildon"><span>Basildon</span></a></li> <li class="areasitem"><a href="computer-repair-services-pitsea"><span>Pitsea</span></a></li> <li class="areasitem"><a href="computer-repair-laindon"><span>Laindon</span></a></li> </ul> </div> <div class="col-md-6"> <ul class="areaslist"> <li class="areasitem"><a href="computer-repair-langdon-hills"><span>Langdon Hills</span></a></li> <li class="areasitem"><a href="computer-repair-wickford"><span>Wickford</span></a></li> </ul> </div> </div> </div>'; ?> Code (markup):
I now need to get it to show on more than one specific blog post, I tried the following code but that makes it appear on all the blog posts if($row['postID'] == '24' || '27') Code (markup): Sorry managed to get this working with the following code <?php if($row['postID'] == '24' || $row['postID'] == '28') Code (markup): Now I need help with a else statement as on some other specific blog posts, I want to display another bit of content/coding. I tried with the following but get a blank white page, I added in php error reporting but shows no errors, just a blank white page, the coding I currently have is below <?php if($row['postID'] == '24' || $row['postID'] == '28') { echo '<div class="article"> <div class="text-center"> <div class="col-md-12"> <h3 class="h-lg text-center">Areas <span class="color">We</span> Cover</span></h3> </div> <div class="col-md-6"> <ul class="areaslist"> <li class="areasitem"><a href="../virus-removal-basildon"><span>Basildon</span></a></li> <li class="areasitem"><a href="../computer-repair-services-pitsea"><span>Pitsea</span></a></li> <li class="areasitem"><a href="../computer-repair-laindon"><span>Laindon</span></a></li> </ul> </div> <div class="col-md-6"> <ul class="areaslist"> <li class="areasitem"><a href="../computer-repair-langdon-hills"><span>Langdon Hills</span></a></li> <li class="areasitem"><a href="../computer-repair-wickford"><span>Wickford</span></a></li> </ul> </div> </div> </div>'; } elseif ($row['postID'] == '27' || $row['postID'] == '29') { echo '<div class="article"> <div class="text-center"> <div class="col-md-12"> <h3 class="h-lg text-center">Areas <span class="color">We</span> Cover</span></h3> </div> <div class="col-md-6"> <ul class="areaslist"> <li class="areasitem"><a href="../computer-repaid-basildon"><span>Basildon</span></a></li> <li class="areasitem"><a href="../computer-repair-services-pitsea"><span>Pitsea</span></a></li> <li class="areasitem"><a href="../computer-repair-laindon"><span>Laindon</span></a></li> </ul> </div> <div class="col-md-6"> <ul class="areaslist"> <li class="areasitem"><a href="../computer-repair-langdon-hills"><span>Langdon Hills</span></a></li> <li class="areasitem"><a href="../computer-repair-wickford"><span>Wickford</span></a></li> </ul> </div> </div> </div>'; ?> Code (markup):
Thought I was winning, the php code below is causing the blank white page, looks like a code error within the code below, can anyone help me correct it please <?php if($row['postID'] == '24' || $row['postID'] == '28') { echo '<div class="article"> <div class="text-center"> <div class="col-md-12"> <h3 class="h-lg text-center">Areas <span class="color">We</span> Cover</span></h3> </div> <div class="col-md-6"> <ul class="areaslist"> <li class="areasitem"><a href="../virus-removal-basildon"><span>Basildon</span></a></li> <li class="areasitem"><a href="../computer-repair-services-pitsea"><span>Pitsea</span></a></li> <li class="areasitem"><a href="../computer-repair-laindon"><span>Laindon</span></a></li> </ul> </div> <div class="col-md-6"> <ul class="areaslist"> <li class="areasitem"><a href="../computer-repair-langdon-hills"><span>Langdon Hills</span></a></li> <li class="areasitem"><a href="../computer-repair-wickford"><span>Wickford</span></a></li> </ul> </div> </div> </div>'; } elseif (($row['postID'] == '27' || $row['postID'] == '29')) { echo '<div class="article"> <div class="text-center"> <div class="col-md-12"> <h3 class="h-lg text-center">Areas <span class="color">We</span> Cover</span></h3> </div> <div class="col-md-6"> <ul class="areaslist"> <li class="areasitem"><a href="../computer-repair-basildon"><span>Basildon</span></a></li> <li class="areasitem"><a href="../computer-repair-services-pitsea"><span>Pitsea</span></a></li> <li class="areasitem"><a href="../computer-repair-laindon"><span>Laindon</span></a></li> </ul> </div> <div class="col-md-6"> <ul class="areaslist"> <li class="areasitem"><a href="../computer-repair-langdon-hills"><span>Langdon Hills</span></a></li> <li class="areasitem"><a href="../computer-repair-wickford"><span>Wickford</span></a></li> </ul> </div> </div> </div>'; ?> Code (markup):
Update: I have sorted the blank white page issue with the amended coding below but now I am unsure how to put multiple id's into the coding, for example I want the article appearing on postID 24 to also appear on postID 28 <?php if ($row['postID'] == "24") { ?> <div class="article"> <div class="text-center"> <div class="col-md-12"> <h3 class="h-lg text-center">Areas <span class="color">We</span> Cover</span></h3> </div> <div class="col-md-6"> <ul class="areaslist"> <li class="areasitem"><a href="../virus-removal-basildon"><span>Basildon</span></a></li> <li class="areasitem"><a href="../computer-repair-services-pitsea"><span>Pitsea</span></a></li> <li class="areasitem"><a href="../computer-repair-laindon"><span>Laindon</span></a></li> </ul> </div> <div class="col-md-6"> <ul class="areaslist"> <li class="areasitem"><a href="../computer-repair-langdon-hills"><span>Langdon Hills</span></a></li> <li class="areasitem"><a href="../computer-repair-wickford"><span>Wickford</span></a></li> </ul> </div> </div> </div> <?php } else if ($row['postID'] == "27") { ?> <div class="article"> <div class="text-center"> <div class="col-md-12"> <h3 class="h-lg text-center">Areas <span class="color">We</span> Cover</span></h3> </div> <div class="col-md-6"> <ul class="areaslist"> <li class="areasitem"><a href="../computer-repair-basildon"><span>Basildon</span></a></li> <li class="areasitem"><a href="../computer-repair-services-pitsea"><span>Pitsea</span></a></li> <li class="areasitem"><a href="../computer-repair-laindon"><span>Laindon</span></a></li> </ul> </div> <div class="col-md-6"> <ul class="areaslist"> <li class="areasitem"><a href="../computer-repair-langdon-hills"><span>Langdon Hills</span></a></li> <li class="areasitem"><a href="../computer-repair-wickford"><span>Wickford</span></a></li> </ul> </div> </div> </div> <? } ?> Code (markup):
I have managed to solve the multiple ids, I altered the code to be a array so now looks like the following and works perfect <?php if (in_array($row['postID'], array(24, 28, 34))) { ?> <div class="article"> <div class="text-center"> <div class="col-md-12"> <h3 class="h-lg text-center">Areas <span class="color">We</span> Cover</span></h3> </div> <div class="col-md-6"> <ul class="areaslist"> <li class="areasitem"><a href="../virus-removal-basildon"><span>Basildon</span></a></li> <li class="areasitem"><a href="../computer-repair-services-pitsea"><span>Pitsea</span></a></li> <li class="areasitem"><a href="../computer-repair-laindon"><span>Laindon</span></a></li> </ul> </div> <div class="col-md-6"> <ul class="areaslist"> <li class="areasitem"><a href="../computer-repair-langdon-hills"><span>Langdon Hills</span></a></li> <li class="areasitem"><a href="../computer-repair-wickford"><span>Wickford</span></a></li> </ul> </div> </div> </div> <?php } else if (in_array($row['postID'], array(27, 29))) { ?> <div class="article"> <div class="text-center"> <div class="col-md-12"> <h3 class="h-lg text-center">Areas <span class="color">We</span> Cover</span></h3> </div> <div class="col-md-6"> <ul class="areaslist"> <li class="areasitem"><a href="../computer-repair-basildon"><span>Basildon</span></a></li> <li class="areasitem"><a href="../computer-repair-services-pitsea"><span>Pitsea</span></a></li> <li class="areasitem"><a href="../computer-repair-laindon"><span>Laindon</span></a></li> </ul> </div> <div class="col-md-6"> <ul class="areaslist"> <li class="areasitem"><a href="../computer-repair-langdon-hills"><span>Langdon Hills</span></a></li> <li class="areasitem"><a href="../computer-repair-wickford"><span>Wickford</span></a></li> </ul> </div> </div> </div> <? } ?> Code (markup):