Programming Tools
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingProgramming Tools

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old July 13th, 2003, 07:48 PM
GandalfTheBrown GandalfTheBrown is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 9 GandalfTheBrown User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Alternating Row Colors.

I set up this news system, and I have displayed it in a "Latest News Headlines" type of table on my site. I would liek alternate row colors. Also, in this table on my site, i have displayed some headlines which I would liek to have linked to my article. How would I do so?

Reply With Quote
  #2  
Old July 13th, 2003, 10:11 PM
iahmed iahmed is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2003
Location: USA
Posts: 171 iahmed User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 42 m 58 sec
Reputation Power: 16
Alternate Row Color
===================

Hints:
----------------

$p=0;
for ($j=0;$j<TotalCount;$j++) {
// display row

$MyColor=($p==0) ? "#FFFFFF":"#F0F0F0";

$p=($p==1) ? 0:1;

}

Reply With Quote
  #3  
Old July 13th, 2003, 10:56 PM
GandalfTheBrown GandalfTheBrown is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 9 GandalfTheBrown User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
<?php
$data = file('news.txt');
$data = array_reverse($data);
foreach($data as $element) {
$element = trim($element);
$pieces = explode("|", $element);
echo "<b>" . $pieces[3] . "</b><BR>" . "<i>Posted by " . $pieces[1] . " on " . $pieces[0] . "</i>\n";
}
?>
that is my script. I still dont understand where to place this. additioanlly, i would like to know how to view a single news article. like, i add a news article and it is viewed as a list of articles. According to the tutorial. But how do I view only one article?

Reply With Quote
  #4  
Old July 14th, 2003, 11:48 AM
nicat23's Avatar
nicat23 nicat23 is offline
Addicted to Chaos..
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jan 2003
Location: Ft. Worth, TX
Posts: 650 nicat23 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 48 m 34 sec
Reputation Power: 0
Send a message via AIM to nicat23 Send a message via Yahoo to nicat23
here's a script I whipped up for you... it's an example for listing mail items in a webmail client... this is just an example (but it does work for me so.. ) It's a little big so... yeah.. but this will alternate the row colors..

PHP Code:
echo "<table border=\"0\" cellpadding=\"5\">\n";
echo 
"  <tr>\n    <th><form name=\"messageList\" action=\"$_SERVER[PHP_SELF]\" METHOD=\"POST\">
    <input type=\"checkbox\" name=\"toggleAll\" title=\"Select or deselect messages\" onclick=\"ToggleAll(this);\">
    </th>\n    <th>From</th>\n    <th>Subject</th>\n    <th>Date</th>\n    <th>Size</th>\n  
    </tr>\n\n"
;
for (
$x=1$x<$numemails+1$x++){
    
$idx = ($x-1);
    
$mailHeader = @imap_headerinfo($conn,$x);
    
$from $mailHeader->fromaddress;
    
$subject strip_tags($mailHeader->subject);
    
$date $mailHeader->date;
    
$tmp imap_fetchstructure($conn$x);
    
$size $tmp->bytes;
    if(
$mailHeader->Unseen == "U" || $mailHeader->Recent =="N"){
        
$msgStat "<tr class = msgold >\n";
    }else{
        
$msgStat "<tr class = msgnew >\n";
    }
    if (
$x 2) { //It's even, paint it one color
        
$msgcol "#DDDDDD";
    } else {
        
$msgcol "#CCCCCC";
    }
    if (
$subject == ""){
        echo 
$msgStat;
        echo 
"    <td bgcolor=\"$msgcol\"><input type=\"checkbox\" name=\"msg-$x\"></td>\n";
        echo 
"    <td bgcolor=\"$msgcol\">$from</td>\n";
        echo 
"    <td bgcolor=\"$msgcol\"><a href=\"?pageMethod=viewMail&num=$x\">No Subject</a></td>\n";
        echo 
"    <td bgcolor=\"$msgcol\">$date</td>\n";
        echo 
"    <td bgcolor=\"$msgcol\">$size</td>\n";
        echo 
"  </tr>\n\n";
    }else{
        echo 
$msgStat;
        echo 
"    <td bgcolor=\"$msgcol\"><input type=\"checkbox\" name=\"msg-$x\"></td>\n";
        echo 
"    <td bgcolor=\"$msgcol\">$from</td>\n";
        echo 
"    <td bgcolor=\"$msgcol\"><a href=\"?pageMethod=viewMail&num=$x\">$subject</a></td>\n";
        echo 
"    <td bgcolor=\"$msgcol\">$date</td>\n";
        echo 
"    <td bgcolor=\"$msgcol\">$size</td>\n";
        echo 
"  </tr>\n\n";
    }
}
echo 
"</table>\n\n";
echo 
"</form>\n"

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingProgramming Tools > Alternating Row Colors.


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap