wordpress footer.php - Parse error: syntax error, unexpected $end - php

Im getting a,
Parse error: syntax error, unexpected $end in /clientdata/zeus-dynamic-1/c/a/careassess.com.au/www/wp-content/themes/wptheme_careassess/includes/footer.php on line 108
I was trying to remove a section from the footer of my clients site and I managed to break their entire footer. Specifically I was trying to remove the Paypal section under 'éngage'
from line 12-18.
Can some tell me where the bug is? I've tried to read up about it buti don't know what I'm looking for.
<?php if( !$fm_is_home ){ ?>
<div id="footer_subscribe">
<?php echo(apply_filters('the_content', '[contact-form 3 "defaultSubscribe"]')); ?>
</div>
<?php } ?>
<div id="footer_container">
<?php if( !$fm_is_home ){ ?>
<ul id="footerNav">
<li<?php checkSelected($ENGAGE_ID); ?>>
<span class="title">engage</span>
<ul>
<?php echo print_page_navigation($ENGAGE_ID, $PAYPAL_ID); ?>
<li><?php $paypalPage = get_page($PAYPAL_ID); ?>
<?php echo($paypalPage->post_title); ?> <img class="paypal" src="<?php bloginfo('template_directory'); ?>/images/btn_paypal.gif" width="44" height="16" alt="paypal" title="paypal" />
</li>
</ul>
</li>
<li<?php checkSelected($REFER_ID); ?>>
<span class="title">refer</span>
<ul>
<?php echo print_page_navigation($REFER_ID); ?>
</ul>
</li>
<li<?php checkSelected($DELIVER_ID); ?>>
<span class="title">deliver</span>
<ul>
<?php echo print_page_navigation($DELIVER_ID); ?>
</ul>
</li>
<li<?php checkSelected($SUPPORT_ID); ?>>
<span class="title">support</span>
<ul>
<?php echo print_page_navigation($SUPPORT_ID); ?>
</ul>
</li>
<li<?php checkSelected($SHARE_ID); ?>>
<span class="title">share</span>
<ul>
<li>
Our latest news
</li>
<?php echo print_page_navigation($SHARE_ID); ?>
<li>
<span class="follow">Follow us:
<img src="<?php bloginfo('template_directory'); ?>/images/btn_twitter.gif" height="32" width="16" alt="Twitter" title="Twitter"/>
<img src="<?php bloginfo('template_directory'); ?>/images/btn_facebook.gif" height="32" width="16" alt="Facebook" title="Facebook"/>
</span>
</li>
</ul>
</li>
</ul>
<?php } ?>
<div id="footer">
<div class="logo">
<img src="<?php bloginfo('template_directory'); ?>/images/footer_logo_careassess.gif" width="149" height="39" alt="Care Assess" title="Care Assess" />
<span class="copyright">© Copyright 2011 <strong>Care Assess</strong>.</span>
</div>
<ul class="nav">
<li>About us</li>
<li<?php if($current_post_ID == $TERMS_ID){ echo(' class="selected"'); } ?>>Terms</li>
<li<?php if($current_post_ID == $POLICIES_ID){ echo(' class="selected"'); } ?>>Policies</li>
<li<?php if($current_post_ID == $AGREEMENTS_ID){ echo(' class="selected"'); } ?>>Agreements</li>
<li<?php if($current_post_ID == $DISCLAIMER_ID){ echo(' class="selected"'); } ?>>Disclaimer</li>
<li<?php if($current_post_ID == $FEEDBACK_ID){ echo(' class="selected"'); } ?>>Feedback</li>
<li<?php if($current_post_ID == $CREDITS_ID){ echo(' class="selected"'); } ?>>Credits</li>
<li<?php if($current_post_ID == $SITEMAP_ID){ echo(' class="selected"'); } ?>>Sitemap</li>
<?php if( $fm_is_home ){ ?>
<li><span id="seoShow">More</span><span id="seoHide">Less</span></li>
<?php } ?>
<li<?php if($current_post_ID == $CONTACT_US_ID){ echo(' class="selected"'); } ?>>Contact Us</li>
</ul>
<?php if (!has_parent_page($SHARE_ID) && $SHARE_ID != $current_post_ID) { ?>
<div class="controls">
<form action="http://www.google.com/translate" id="language" target="_blank">
<fieldset>
<input name="u" value="<?php bloginfo('url'); ?>" type="hidden" />
<input name="hl" value="en" type="hidden" />
<input name="ie" value="UTF8" type="hidden" />
</fieldset>
<fieldset>
<img class="google_icon" src="<?php bloginfo('template_directory'); ?>/images/google_icon.gif" width="19" height="20" alt="google" title="google" />
<select name="langpair" onchange="document.forms['language'].submit()">
<option value="en|en">English</option>
<option value="en|fr">French</option>
<option value="en|de">German</option>
<option name="langpair" value="en|it">Italian</option>
<option name="langpair" value="en|pt">Portuguese</option>
<option name="langpair" value="en|es">Spanish</option>
<option name="langpair" value="en|ja">Japanese</option>
<option name="langpair" value="en|ko">Korean</option>
<option name="langpair" value="en|zh-CN">Chinese Simplified</option>
</select>
</fieldset>
</form>
<ul>
<li class="addthisLi">
<!-- AddThis Button BEGIN -->
<div class="addthis_toolbox addthis_default_style">
<a class="rss btn" href="http://www.careassess.com.au/feed/"><img src="<?php bloginfo('template_directory'); ?>/images/btn_addthis_rss.png" width="25" height="48" alt="RSS" title="RSS" /></a>
<a class="addthis_button_facebook btn"><img src="<?php bloginfo('template_directory'); ?>/images/btn_addthis_facebook.png" width="25" height="48" alt="Facebook" title="Facebook" /></a>
<a class="addthis_button_twitter btn"><img src="<?php bloginfo('template_directory'); ?>/images/btn_addthis_twitter.png" width="25" height="48" alt="Twitter" title="Twitter" /></a>
<a class="addthis_button_google btn"><img src="<?php bloginfo('template_directory'); ?>/images/btn_addthis_google.png" width="25" height="48" alt="Google" title="Google" /></a>
<a class="addthis_button_email btn"><img src="<?php bloginfo('template_directory'); ?>/images/btn_addthis_email.png" width="25" height="48" alt="Email" title="Email" /></a>
<!--<a class="addthis_button_compact btn"><img src="<?php
Any help would be greatly appreciated!
I've certainly learnt my lesson about editing theme files when your a noob :(

You have to close if conditions,i doesn't saw whether it's has been closed and line 108 not fully shown in given link please can you give proper code.

<?php if (!has_parent_page($SHARE_ID) && $SHARE_ID != $current_post_ID) { ?>
didn't see that being closed, unless I am mistaken.
Add:
<?php } ?>
To fix the issue!

Add following line in last
</div></li></ul>
<?php } ?>
</body>
</html>

Related

Undefined offset: 2 while using explode

I have $product_image='img1.png,img2.png,img3.png' as a string where I explode $product_image and show image as $pro_img[0], $pro_img[1] and $pro_img[2].
I get error
Message: Undefined offset: 2
if $pro_img[2] doesn't find any image.
I want to solve it using foreach loop but I don't have any idea how can I use foreach to fix this problem?
<?php $pro_img = explode(",",$product_image); ?>
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade show active" id="home" role="tabpanel" aria-labelledby="home-tab">
<div class="pro-large text-center">
<img src="<?php echo base_url(); ?>resource/product/<?php echo $pro_img[0]; ?>" style="width: 50%;height: 35%;" alt="">
</div>
</div>
<div class="tab-pane fade" id="profile" role="tabpanel" aria-labelledby="profile-tab">
<div class="pro-large text-center">
<img src="<?php echo base_url(); ?>resource/product/<?php echo $pro_img[1]; ?>" style="width: 50%;height: 35%;" alt="">
</div>
</div>
<div class="tab-pane fade" id="contact" role="tabpanel" aria-labelledby="contact-tab">
<div class="pro-large text-center">
<img src="<?php echo base_url(); ?>resource/product/<?php echo $pro_img[2]; ?>" style="width: 50%;height: 35%;" alt="">
</div>
</div>
</div>
<ul class="nav product-img-tab" id="myTab" role="tablist">
<li class="nav-item">
<a class="nav-link active" id="home-tab" data-toggle="tab" href="#home" role="tab" aria-controls="home" aria-selected="true">
<img src="<?php echo base_url(); ?>resource/product/<?php echo $pro_img[0]; ?>" style="width: 50%;height: 96px;" alt="">
</a>
</li>
<li class="nav-item">
<a class="nav-link" id="profile-tab" data-toggle="tab" href="#profile" role="tab" aria-controls="profile" aria-selected="false">
<img src="<?php echo base_url(); ?>resource/product/<?php echo $pro_img[1]; ?>" style="width: 50%;height: 96px;" alt="">
</a>
</li>
<li class="nav-item">
<a class="nav-link" id="contact-tab" data-toggle="tab" href="#contact" role="tab" aria-controls="contact" aria-selected="false">
<img src="<?php echo base_url(); ?>resource/product/<?php echo $pro_img[2]; ?>" style="width: 50%;height: 96px;" alt="">
</a>
</li>
</ul>
Since you have various sections (home/profile/contact), that I assume you always want to display either with or without an image, I suggest using isset instead.
Isset simply checks if a key exists in the $pro_img array, and you can use that to decide whether or not to print the image tag:
<?php
$pro_img = explode(",",$product_image);
?>
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade show active" id="home" role="tabpanel" aria-labelledby="home-tab">
<div class="pro-large text-center">
<?php if (isset($pro_img[0])) : ?>
<img src="<?php echo base_url(); ?>resource/product/<?php echo $pro_img[0]; ?>" style="width: 50%;height: 35%;" alt="">
<?php endif; ?>
</div>
</div>
<div class="tab-pane fade" id="profile" role="tabpanel" aria-labelledby="profile-tab">
<div class="pro-large text-center">
<?php if (isset($pro_img[1])) : ?>
<img src="<?php echo base_url(); ?>resource/product/<?php echo $pro_img[1]; ?>" style="width: 50%;height: 35%;" alt="">
<?php endif; ?>
</div>
</div>
<div class="tab-pane fade" id="contact" role="tabpanel" aria-labelledby="contact-tab">
<div class="pro-large text-center">
<?php if (isset($pro_img[2])) : ?>
<img src="<?php echo base_url(); ?>resource/product/<?php echo $pro_img[2]; ?>" style="width: 50%;height: 35%;" alt="">
<?php endif; ?>
</div>
</div>
</div>
<ul class="nav product-img-tab" id="myTab" role="tablist">
<li class="nav-item">
<a class="nav-link active" id="home-tab" data-toggle="tab" href="#home" role="tab" aria-controls="home" aria-selected="true">
<?php if (isset($pro_img[0])) : ?>
<img src="<?php echo base_url(); ?>resource/product/<?php echo $pro_img[0]; ?>" style="width: 50%;height: 96px;" alt="">
<?php endif; ?>
</a>
</li>
<li class="nav-item">
<a class="nav-link" id="profile-tab" data-toggle="tab" href="#profile" role="tab" aria-controls="profile" aria-selected="false">
<?php if (isset($pro_img[1])) : ?>
<img src="<?php echo base_url(); ?>resource/product/<?php echo $pro_img[1]; ?>" style="width: 50%;height: 96px;" alt="">
<?php endif; ?>
</a>
</li>
<li class="nav-item">
<a class="nav-link" id="contact-tab" data-toggle="tab" href="#contact" role="tab" aria-controls="contact" aria-selected="false">
<?php if (isset($pro_img[2])) : ?>
<img src="<?php echo base_url(); ?>resource/product/<?php echo $pro_img[2]; ?>" style="width: 50%;height: 96px;" alt="">
<?php endif; ?>
</a>
</li>
</ul>

Div class inside echo PHP

I try to put div class in the echo but it does not work really well. The coding is for to change the login button to the username button after user login. The username button will have the drop-down which is the div class. Other things are work well in this coding except for the div class drop-down. Is there another way to put the div class in the echo? Any thought??
This is before login
What I expected after Login
What I get after Login
Below is my coding:
<div class="header-right">
<?php
if (isset($_SESSION['login_user'])) {
echo '<a class="active" ><img src="image/user.png" width="22" height="22"> '.$login_session.' <img src="image/drop.png" width="20" height="20" > </a>';
echo '<div class="box dropdown">
<ul>
<a "">edit</a>
<a "">delete</a>
<a id="logout" href="logout.php">Log Out</a>
</ul>
</div>';
} else {
echo '<a class="active" href="login.php"><img src="image/lock.png" width="20" height="20"> Login</a>' ;
}
?>
</div>
I use another way to write down this. Let me know if you have any question. I fixed some attribute missing into your anchors <a> and list some <li> elements into your <ul> element as well.
<div class="header-right">
<?php if (isset($_SESSION['login_user'])) { ?>
<a class="active" >
<img src="image/user.png" width="22" height="22">
<?= $login_session ?>
<img src="image/drop.png" width="20" height="20" >
</a>
<div class="box dropdown">
<ul>
<li>edit</li>
<li>delete</li>
<li><a id="logout" href="logout.php">Log Out</a></li>
</ul>
</div>
<?php } else { ?>
<a class="active" href="login.php"><img src="image/lock.png" width="20" height="20"> Login</a>
<?php } ?>
</div>
You may put your code in the way like below and I found out your <ul> is missing <li>.
<div class="header-right">
<?php if(isset($_SESSION['login_user'])): ?>
<!-- Login User (HTML) -->
<?php else: ?>
<!-- Not Login User (HTML) -->
<?php endif; ?>
</div>
<?php if (isset($_SESSION['login_user'])) { ?>
<a class="active" >
<img src="image/user.png" width="22" height="22">
<?php $login_session ?>
<img src="image/drop.png" width="20" height="20" >
</a>
<div class="box dropdown">
<ul>
<li>edit</li>
<li>delete</li>
<li><a id="logout" href="logout.php">Log Out</a></li>
</ul>
</div>
<?php } else { ?>
<a class="active" href="login.php"><img src="image/lock.png" width="20" height="20"> Login</a>
<?php } ?>
</div>

PHP Menu item breaks all following menu items

The menus are all separated into PHP includes and called in the main index.php file. The issue is all of the menu items work fine until a specific menu item. At which point that linked page and all of the following links after it in the menu stop functioning without any sort of inspector error. The problem page is titled eva.php. From what I can tell the original creator of the site has all of the pages are being called correctly, but I'm fairly new to PHP so forgive any ignorance on my part.
Index File:
<!doctype html>
<html lang="en">
<head>
<?php require_once('inc/meta.php'); ?>
<?php require_once('inc/script.php'); ?>
<?php require_once('inc/styles.php'); ?>
</head>
<body>
<div id="slidemenu" class="scrollable closed">
<ul id="menuAll">
<h2>Applications</h2>
<li>Furniture, Cabinet & Countertop Substrates</li>
<li>Engineered Flooring Substrates</li>
<li>Flooring, Furniture, Cabinet & Countertop Laminates</li>
<li>Molding & Millwork</li>
<li>Doors & Windows</li>
<li>Framing</li>
<li>Sheathing</li>
<li>Roofing</li>
<li>Insulation</li>
<li>Decks, Porches, Cladding & Fences</li>
<h2>More</h2>
<li>Sustainability</li>
<li>Formaldehyde in Construction Video</li>
</ul>
<?php require_once('inc/menu-framing.php'); ?>
<?php require_once('inc/menu-cabinets-counters.php'); ?>
<?php require_once('inc/menu-flooring-furniture-cabinets-counters.php'); ?>
<?php require_once('inc/menu-doors-windows.php'); ?>
<?php require_once('inc/menu-furniture.php'); ?>
<?php require_once('inc/menu-sheathing.php'); ?>
<?php require_once('inc/menu-roofing.php'); ?>
<?php require_once('inc/menu-insulation.php'); ?>
<?php require_once('inc/menu-moulding-millwork.php'); ?>
<?php require_once('inc/menu-engineered-flooring.php'); ?>
<?php require_once('inc/menu-locations.php'); ?>
<?php require_once('inc/menu-decks.php'); ?>
</div>
<div data-role="page" id="main_page" data-theme="a">
<div data-role="header"> ☰
</div>
</div>
<?php require_once('inc/page-other.php'); ?>
<?php require_once('inc/page-urea-formaldehyde.php'); ?>
<?php require_once('inc/page-melamine-formaldehyde-powder.php'); ?>
<?php require_once('inc/page-melamine-urea-formaldehyde.php'); ?>
<?php require_once('inc/page-resorcinol-formaldehyde.php'); ?>
<?php require_once('inc/page-phenol-resorcinol-formaldehyde.php'); ?>
<?php require_once('inc/page-emulsion-polymerized-isocyanate.php'); ?>
<?php require_once('inc/page-polyvinyl-acetate.php'); ?>
<?php require_once('inc/page-polyurethane-dispersions.php'); ?>
<?php require_once('inc/page-hot-melts.php'); ?>
<?php require_once('inc/page-casein-glues.php'); ?>
<?php require_once('inc/page-phenol-formaldehyde.php'); ?>
<?php require_once('inc/page-phenol-formaldehyde-adhesive.php'); ?>
<?php require_once('inc/page-phenol-formaldehyde-powder.php'); ?>
<?php require_once('inc/page-phenol-resorcinol-based-resins.php'); ?>
<?php require_once('inc/page-wax-emulsions.php'); ?>
<?php require_once('inc/page-melamine-urea-phenol-formaldehyde.php'); ?>
<?php require_once('inc/page-pva-adhesives.php'); ?>
<?php require_once('inc/page-melamine-based-resins.php'); ?>
<?php require_once('inc/page-melamine-resorcinol-based-resins.php'); ?>
<?php require_once('inc/page-resorcinol-based-resins.php'); ?>
<?php require_once('inc/page-fentak.php'); ?>
<?php require_once('inc/page-osb-specialized.php'); ?>
<?php require_once('inc/page-phenolic-resins.php'); ?>
<?php require_once('inc/page-amino-resins.php'); ?>
<?php require_once('inc/page-wood.php'); ?>
<?php require_once('inc/page-eva.php'); ?> <-- PROBLEM PAGE
<?php require_once('inc/page-lvl-ready.php'); ?>
<?php require_once('inc/page-lvl-reactor.php'); ?>
<?php require_once('inc/page-lvl-in-plant.php'); ?>
<?php require_once('inc/page-sustainability.php'); ?>
<?php require_once('inc/page-video1.php'); ?>
<?php require_once('inc/page-video2.php'); ?>
<?php require_once('inc/page-na.php'); ?>
<?php require_once('inc/page-sa.php'); ?>
<?php require_once('inc/page-apac.php'); ?>
<?php require_once('inc/page-europe.php'); ?>
</body>
</html>
Menu Include:
<ul id="menuFlooringFurnitureCabinetsCounters">
<h2>Flooring, Furniture, Cabinet & Countertop Laminates</h2>
<li><a href="#">
<img src="img/thumb/particleboard.jpg" width="70" height="70" />
<h3>Countertop Laminates</h3></a>
<ul>
<h4>Countertop Laminates</h4>
<li><a data-prefetch href="#page-urea-formaldehyde">Urea Formaldehyde Resins</a></li>
<li><a data-prefetch href="#page-melamine-formaldehyde-powder">Melamine Formaldehyde Resins</a></li>
<li><a data-prefetch href="#page-melamine-urea-formaldehyde">Melamine-Urea Formaldehyde Resins</a></li>
<li><a data-prefetch href="#page-polyvinyl-acetate">Polyvinyl Acetate Adhesives</a></li>
<li><a data-prefetch href="#page-eva">Ethylene Vinyl Acetate Adhesives</a></li>
<li><a data-prefetch href="#page-fentak">Fentak Additives</a></li>
</ul>
</li>
<li><a href="#">
<img src="img/thumb/mdf.jpg" width="70" height="70" />
<h3>Cabinet Laminates</h3></a>
<ul>
<h4>Cabinet Laminates</h4>
<li><a data-prefetch href="#page-fentak">Fentak Additives</a></li>
<li><a data-prefetch href="#page-urea-formaldehyde">Urea Formaldehyde Resins</a></li>
<li><a data-prefetch href="#page-melamine-urea-formaldehyde">Melamine-urea Formaldehyde Resins</a></li>
<li><a data-prefetch href="#page-melamine-formaldehyde-powder">Melamine Formaldehyde Resins</a></li>
<li><a data-prefetch href="#page-polyvinyl-acetate">Polyvinyl Acetate Adhesives</a></li>
<li><a data-prefetch href="#page-eva">Ethylene Vinyl Acetate Adhesives</a></li>
</ul>
</li>
<li><a href="#">
<img src="img/thumb/plywood.jpg" width="70" height="70" />
<h3>Flooring Laminates</h3></a>
<ul>
<h4>Flooring Laminates</h4>
<li><a data-prefetch href="#page-fentak">Fentak Additives</a></li>
<li><a data-prefetch href="#page-urea-formaldehyde">Urea Formaldehyde Resins</a></li>
<li><a data-prefetch href="#page-melamine-urea-formaldehyde">Melamine-urea Formaldehyde Resins</a></li>
<li><a data-prefetch href="#page-melamine-formaldehyde-powder">Melamine Formaldehyde Resins</a></li>
<li><a data-prefetch href="#page-pva-adhesives">Polyvinyl Acetate Adhesives</a></li>
</ul>
</li>
</ul>
Eva Page:
<div data-role="page" id="page-eva" data-theme="a" data-cache="never">
<div data-role="header"> ☰
</div>
<div data-role="content" id="eva-ethylene-vinyl-acetate">
<div class="form"></div><div class="pad">
</div>
</div>

DOM scripting getElementsByID -- links

I'm learning php and DOM. And i have issue. So, I am trying to improve and understand the following. I have some links with ID div and I am attaching event on them:
<div id='articleList1' >
<div class="hotOne">
<a class="" href="http://link1/index.html" >
<span class="itemTitle">
1 title
</span>
<img src="1.jpg" class=""
alt="1"
title="1"
border="0"
/>
</a>
</div>
<div class="hotThree">
<ul>
<li class="item item1 ">
<a href="http://link2/index.html" title="2" >
<span class="itemTitle">
2 title
</span> <img src="2.jpg" class=""
alt="2"
title="2"
border="0"
/> <p> 2 tekst </span> </p> </a>
</li>
<li class="item item2 ">
<a href="http://link3.html" title="3" >
<span class="itemTitle">
3 title
</span> <img src="3.jpg" class=""
alt="3"
title="3"
border="0"
/> <p> 3 tekst </span> </p> </a>
</li>
</div>
<?php $div1 = $dom->getElementById('articleList1');
$href = $div1->getElementsByTagName('a');
foreach ($href as $hrefs) {
$link = $hrefs->getAttribute('href');
}
echo '<a href ="'.$link.'">'.$link.'<br>'); ?>
However, this script does not work. And I don't know why it's not work?.
Thx for all answers.
Your HTML markup is pretty poor - there are mistakes creeping in which will not help working with the DOM.
<div id='articleList1' >
<div class="hotOne">
<a class="" href="http://link1/index.html" >
<span class="itemTitle">1 title</span>
<img src="1.jpg" class="" alt="1" title="1" border="0" />
</a>
</div>
<div class="hotThree">
<ul>
<li class="item item1 ">
<a href="http://link2/index.html" title="2" >
<span class="itemTitle">2 title</span>
<img src="2.jpg" class="" alt="2" title="2" border="0" />
<p>2 tekst</p><!-- <~~~ error here previously -->
</a>
</li>
<li class="item item2 ">
<a href="http://link3.html" title="3" >
<span class="itemTitle">3 title</span>
<img src="3.jpg" class="" alt="3" title="3" border="0" />
<p>3 tekst</p><!-- <~~~ error here previously -->
</a>
</li>
</ul><!-- missing -->
</div>
</div><!-- missing -->
<?php
$col=$dom->getElementsByTagName('a');
foreach( $col as $node ){
if( $node->nodeType===XML_ELEMENT_NODE && $node->hasAttribute('href') ){
echo $node->getAttribute('href');
}
}
?>
in iteration over $hrefs - refer to dingle href instead of list:
foreach ($href as $hrefs) {
$link = $href->getAttribute('href'); //not $hrefs->
}

can't seem to get the variable to change

I am trying to display blog posts from a MySQL data base into an unordered list. I want each row to display the title an image and short description of 3 entries. Here is an example:
<ul class="submissions">
<li class="first">
<a href="url"> <img alt="image Alt" class="blog_image" height="198" src="image url" title="blog title" width="276" />
</a> <div class="submissions_content">
<h3>blog title</h3>
<p> blog discription .</p>
</div>
</li> <li class="second">
<a href="url">
<img alt="image Alt" class="blog_image" height="198" src="image url" title="blog title" width="276" />
</a> <div class="submissions_content">
<h3>blog title</h3>
<p> blog discription .</p>
</div>
</li> <li class="last">
<a href="url">
<img alt="image Alt" class="blog_image" height="198" src="image url" title="blog title" width="276" />
</a> <div class="submissions_content">
<h3>blog title</h3>
<p> blog discription .</p>
</div>
</li> <li class="first">
<a href="url">
<img alt="image Alt" class="blog_image" height="198" src="image url" title="blog title" width="276" />
</a> <div class="submissions_content">
<h3>blog title</h3>
<p> blog discription .</p>
</div>
</li> <li class="second">
<a href="url">
<img alt="image Alt" class="blog_image" height="198" src="image url" title="blog title" width="276" />
</a> <div class="submissions_content">
<h3>blog title</h3>
<p> blog discription .</p>
</div>
</li> <li class="last">
<a href="url">
<img alt="image Alt" class="blog_image" height="198" src="image url" title="blog title" width="276" />
</a> <div class="submissions_content">
<h3>blog title</h3>
<p> blog discription .</p>
</div>
</li></ul>
You see how the li class changes for each entry? I tried this code but the li class ends up being the same for every entry:
<ul class="submissions">
<?php
mysql_connect ('localhost', 'root', '072868') ;
mysql_select_db ('test');
$sql = "SELECT * FROM tbp_blog ORDER BY timestamp DESC LIMIT 5";
$result = mysql_query($sql) or print ("Can't select entries from table tbp_blog.<br />" . $sql . "<br />" . mysql_error());
while($row = mysql_fetch_array($result)) {
$date = date("l F d Y g:i:s A", $row['timestamp']);
$link = $row['link'];
$title = stripslashes($row['title']);
$description = stripslashes($row['description']);
$entry = stripslashes($row['entry']);
$image_link = $row['image_link'];
$image_alt = $row['image_alt'];
$id = $row['id'];
$li_class = 'first';
?>
<li class="<?php echo $li_class ; ?>">
<img alt="<?php echo $image_alt; ?>" class="blog_image" height="198" src="<?php echo $image_link; ?>" title="<?php echo $title; ?>" width="276" />
<div class="submissions_content"><h3><?php echo $title; ?></h3>
<p><?php echo $description; ?></p>
</div>
</li>
<?php if ($li_class == 'first') {
$li_class = 'second';
} elseif ($li_class == 'second') {
$li_class = 'last';
} elseif ($li_class == 'fist') {
$li_class == 'first';
}
?>
<?php
}
?>
</ul>
what am I doing wrong?
Move $li_class = 'first'; outside of your while condition. You're resetting it on every iteration.
$li_class = 'first';
put this line OUTSIDE of your while loop:
while($row = mysql_fetch_array($result)) {

Categories