Current location: Hot Scripts Forums » Programming Languages » PHP » loop problem


loop problem

Reply
  #1 (permalink)  
Old 01-28-09, 04:58 AM
umarrana umarrana is offline
Newbie Coder
 
Join Date: Dec 2006
Location: Pakistan
Posts: 44
Thanks: 0
Thanked 0 Times in 0 Posts
loop problem

hello friends i am displaying some article in a loop from database and i am trying to add a different css class after every record so my record will show in row lines please guide who its possible

here is my code

PHP Code:

while($rows=mysql_fetch_array($query ))

                                    {    
                                        
                                                                    
                                        
$showsafe.= "<div class='article1'>
                            <div class='art_tit'>"
.$rows['news_title']."</div>
                            <div class='art_des'>
                                <div class='art_txtNimg'>Featuring <a href=news.html>"
.$rows['news_title']."</a>(".substr($rows['news_desc'],0,58).")</div>
                                <div class='art_img'><img src='upload/thumbs/"
.$rows['news_pic']."' width='130' height='89' /></div>
                            </div>
                          </div>"
;                                 
                                
                                    } 
i am trying to change the <div class='article1'> after every new record like this <div class='article2'> please if there is any salutation

and body can guide me thanks in advance
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 01-28-09, 06:29 AM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,516
Thanks: 20
Thanked 109 Times in 106 Posts
You might want to use a highlight and toggle.


PHP Code:

$bToggle=false;

while (...)
{
$bToggle=!$bToggle;
$sHighlight='<div class=".($bToggle)?'highlight':'nohighlight'.'">';
...

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 01-28-09, 06:50 AM
umarrana umarrana is offline
Newbie Coder
 
Join Date: Dec 2006
Location: Pakistan
Posts: 44
Thanks: 0
Thanked 0 Times in 0 Posts
thanks for your reply can you more explain this i mean who to implement this on my code
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
layout problem with while loop sondogg CSS 5 02-21-08 11:57 AM
Iterating Associative arrays with foreach divya PHP 13 11-21-07 02:12 PM
A Language filter problem, and a problem with a for loop querying my database. . . Spreegem PHP 6 05-08-05 12:03 PM
Having a problem with a large while loop. . . Spreegem PHP 13 05-03-05 06:53 AM
SQL infinite loop problem with VB application Syed Visual Basic 2 05-07-04 11:19 AM


All times are GMT -5. The time now is 11:33 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.