Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 11-02-2009, 10:25 AM   #1 (permalink)
jnich104
Monkey N00B
 
jnich104's Avatar
 
Join Date: Jun 2008
Location: Nailsea
Posts: 107
jnich104 is on a distinguished road
Send a message via MSN to jnich104
Mysql 2 post

how to i make it so that every second post is differnet

like

PHP Code:
$connect mysql_connect('asd','asd','asd');

Blah Blah Blah

while($row mysql_fetch_array($result))
      {
        echo 
'<div class="1">'.$row['show_date'].'</div>' ;
      } 
But then for post number 2,4,6,8,10 ect..

something like

PHP Code:
$connect mysql_connect('asd','asd','asd');

Blah Blah Blah

while($row mysql_fetch_array($result))
      {
        echo 
'<div class="2">'.$row['show_date'].'</div>' ;
      } 
Class number changed



Anyone got a idea?
__________________
Jamie Nicholls - Feel Free To Ask Questions
jnich104 is offline   Reply With Quote
Old 11-02-2009, 11:21 AM   #2 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,700
sde is on a distinguished road
PHP Code:
<?php
// initialize your iterator
$i=0;

// loop through result set
while ($row db_fetch_array($result)) {

  
// use the modulus operator to get the remainder of the iterator divided by 2
  // even numbers will always have a remainder of 0 when divided by 2
  
$class $i%2==0?'even':'odd';

  
// echo your div with your new class
  
echo '<div class="'$class .'">'$row['show_date'] .'</div>';

  
// increment your iterator
  
$i++;
}
?>
__________________
Mike
sde is offline   Reply With Quote
Old 11-03-2009, 03:55 AM   #3 (permalink)
jnich104
Monkey N00B
 
jnich104's Avatar
 
Join Date: Jun 2008
Location: Nailsea
Posts: 107
jnich104 is on a distinguished road
Send a message via MSN to jnich104
Thanks
__________________
Jamie Nicholls - Feel Free To Ask Questions
jnich104 is offline   Reply With Quote
Reply

Bookmarks

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
GET and POST with JSP sde Java 1 12-30-2004 03:30 PM
sending POST multiple post requests in one php script. sde PHP 2 08-09-2003 06:10 PM
My first post, I need help Zenogear11 Standard C, C++ 14 03-20-2003 12:01 PM


All times are GMT -8. The time now is 10:18 PM.


Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0 RC8 ©2007, Crawlability, Inc.





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting