Click to See Complete Forum and Search --> : [RESOLVED] Beginner ?: Updating .html table data from a .csv file


KateM
04-12-2009, 10:33 PM
I am working on a simple xhtml website and don't know xml yet. I want to update multiple tables across the site with the same data. Today, I did the following in order to update the table with data from a .csv file. Then I learned that it uses an ActiveX control (tabular data control) and only works on IE. That won't do.

Without getting into setting up a database or Cold Fusion and who-knows-what-else that is beyond my abilities right now, is there a simple way to do this? I know a little php and a little less javascript, and I use Dreamweaver. Here's what I did today, but I need something that will work in other browsers. Seems like it SHOULD be easy!

Thanks in advance for any help.


<table datasrc='#rates' width="200" border="2" cellspacing="5" cellpadding="5">
<thead>
<tr>
<th width="78" scope="col">Item 1</th>
<th width="78" scope="col">Item 2</th>
</tr>
</thead>
<tbody>
<tr>
<td><div align="center"><strong><span datafld='item1'></span></strong></div></td>
<td><div align="center"><strong><span datafld='item2'></span></strong></div></td>
</tr>
</tbody>
</table>

<OBJECTID=rates CLASSID="clsid:333C7BC4-460F-11D0-BC04-0080C7055A83">
<PARAM NAME="DataURL" VALUE="rates.csv">
<PARAM NAME="UseHeader" VALUE="true">
</OBJECT>

KateM
04-13-2009, 12:18 AM
I partly solved the problem when another thread reminded me of the php include. However, does the whole page need to be saved with as a .php file for any php within the page to work? Here is how I approached it, but in order for this to work, I need to save the file as .php and the owner of the site wants all user accessable pages to be .html pages if possible.

<table width="200" border="2" cellspacing="5" cellpadding="5">
<thead>
<tr>
<th width="78" scope="col">Item 1</th>
<th width="78" scope="col">Item 2</th>
</tr>
</thead>
<tbody>
<tr>
<td><div align="center"><strong><span>
<?php
include 'rates.php';
echo "$item1";
?>
</span></strong></div></td>
<td><div align="center"><strong><span>
<?php
include 'rates.php';
echo "$item2";
?>
</span></strong></div></td>
</tr>
</tbody>
</table>



rates.php:

<?php

$item1 = 'Enter Rate for Item 1';
$item2 = 'Enter Rate for Item 2';

?>

Fang
04-13-2009, 01:40 AM
Use the .htaccess file to parse .html files as phpAddType application/x-httpd-php .html

KateM
04-13-2009, 03:59 PM
Thank you, Fang! That worked like a charm. Things are pretty easy when you have the know-how! Thanks for sharing it!