Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #5  
Old 05-21-2015, 03:01 AM
pityocamptes's Avatar
pityocamptes pityocamptes is offline
 
Join Date: Apr 2010
Posts: 595
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I was getting help from stack overflow. This looks like it might work, have not tried it yet. The poster indicated that code needs to be changed to get this to work in a widget. What do I need to change in the following code to get it to work, along with where to I place the css file (additional.css)??? Thanks.

Code:
<?php
$count = 0;
$input = 'https://www.fdic.gov/bank/individual/failed/banklist.csv';
echo "<html><body><table width='250' class='TFtable' >";
echo "<tr>";
echo "<th bgcolor=#222937><FONT COLOR=WHITE SIZE=3>Bank Name</FONT></th>";
echo "<th bgcolor=#222937><FONT COLOR=WHITE SIZE=3>City</FONT></th>";
echo "<th bgcolor=#222937><FONT COLOR=WHITE SIZE=3>Acq. Institution</FONT></th>";
echo "<th bgcolor=#222937><FONT COLOR=WHITE SIZE=3>Closing Date</FONT></th>";
echo "</tr>";

if (false !== ($ih = fopen($input, 'r'))) 
{
fgetcsv($ih);
    while (false !== ($data = fgetcsv($ih))) 
    {    
        $outputData = array($data[0], $data[1], $data[4], $data[5]); 

        echo "<tr>";

            foreach ($outputData as $row)
            {               
                echo "<td><FONT COLOR=D3AB04 SIZE=2>" . htmlspecialchars($row) . "</FONT></td>";
                $count++;               

            }   

        echo "</tr>";
    }

    fclose($ih);
    echo "</table></body></html>";
}

?>
Code:
<style type="text/css">
    .TFtable{
        width:100%; 
        border-collapse:collapse; 
    }
    .TFtable td{ 
        padding:7px; border:#4e95f4 1px solid;
    }
    /* provide some minimal visual accomodation for IE8 and below */
    .TFtable tr{
        background: #b8d1f3;
    }
    /*  Define the background color for all the ODD background rows  */
    .TFtable tr:nth-child(odd){ 
        background: #b8d1f3;
    }
    /*  Define the background color for all the EVEN background rows  */
    .TFtable tr:nth-child(even){
        background: #dae5f4;
    }
</style>
--------------- Added [DATE]1432184580[/DATE] at [TIME]1432184580[/TIME] ---------------

Quote:
Originally Posted by Replicant View Post
I added a class to the rows and use CSS to color the backgrounds. You could add a class for the TD tags as well and use CSS to set the font and color too.
Code:
<?php

$count = 1;

$input = 'https://www.fdic.gov/bank/individual/failed/banklist.csv';

echo "<html><body><table border=1 width=250>";
echo "<style>
tr.row:nth-child(odd) {
    background: blue;
}

tr.row:nth-child(even) {
    background: black;
}

</style>";

echo "<th bgcolor=#222937><FONT  COLOR=WHITE FACE=Geneva, Arial SIZE=3>Bank Name</FONT></th>";
echo "<th bgcolor=#222937><FONT  COLOR=WHITE FACE=Geneva, Arial SIZE=3>City</FONT></th>";
echo "<th bgcolor=#222937><FONT  COLOR=WHITE FACE=Geneva, Arial SIZE=3>Acq. Institution</FONT></th>";
echo "<th bgcolor=#222937><FONT  COLOR=WHITE FACE=Geneva, Arial SIZE=3>Closing Date</FONT></th>";


if (false !== ($ih = fopen($input, 'r'))) 
{
fgetcsv($ih);
    while (false !== ($data = fgetcsv($ih))) 
    {    
        $outputData = array($data[0], $data[1], $data[4], $data[5]); 
		
		echo "<tr class=row >";
		
		foreach ($outputData as $row)
		{
			echo "<td ><FONT COLOR=D3AB04 FACE=Geneva, Arial SIZE=2>" . htmlspecialchars($row) . "</FONT></td>";
			$count++;
		
        }	
		
    }

    fclose($ih);
	echo "</table></body></html>";
}

?>


Ok, thanks. That is what someone on stackoverflow did. Could you please let me know what I need to change in the above code to get it to work in the widget? You mentioned something about the object? Also, how do I get the css to work? Thanks again!

--------------- Added [DATE]1432184792[/DATE] at [TIME]1432184792[/TIME] ---------------

Hey that worked nice!!! How do I get rid of the borders? ALso, what do I need to change in the code to get it to run in a widget? Thanks again!
Reply With Quote
 


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

Forum Jump


All times are GMT. The time now is 03:58 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.10731 seconds
  • Memory Usage 2,663KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (11)bbcode_code
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (11)post_thanks_box
  • (1)post_thanks_box_bit
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (11)post_thanks_postbit_info
  • (11)postbit
  • (1)postbit_attachment
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)showthread_list
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_threadedmode.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids_threaded
  • showthread_threaded_construct_link
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • postbit_attachment
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete