Page 1 of 1

Tables from hell

Posted: Sun Aug 01, 2010 2:01 pm
by lang79james
OK right now I got me some Ugly code
this is just a snippet of it

Code: Select all

<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;">
<table class="MsoNormalTable" style="border-style: none; border-width: medium; font-size: 10pt; border-collapse: collapse; text-align: left; margin-left: auto; margin-right: auto;" border="1" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="border: 1pt solid windowtext; padding: 0in 5.4pt; background-color: rgb(153, 153, 153); width: 92.15pt;" valign="top" width="123">
<p style="margin-top: 0in; margin-bottom: 0pt; text-align: center;" class="MsoNormal" align="center">
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;">
<span style="color: white; font-family: Tahoma,sans-serif;">
<o:p>
<br />
</o:p>
</span>
</span>
</p>                                              
</td>
<td style="border-color: windowtext windowtext windowtext rgb(236, 233, 216); border-top: 1pt solid windowtext; border-right: 1pt solid windowtext; border-bottom: 1pt solid windowtext; padding: 0in 5.4pt; background-color: rgb(153, 153, 153); width: 92.15pt;" valign="top" width="123">
<p class="MsoNormal" style="margin: 0in 0in 0pt; text-align: center;" align="center">
<span style="color: white; font-family: Tahoma,sans-serif;">300W
<o:p />
</span>
now i kinda clean it up

Code: Select all

<table border="1"  align="center" cellspacing="0" width="600"> 
<tr align="Center" valign="top" bgcolor= "grey";>


<td width="20">     </td>
<td width="20"><font color="white">300W </td>
<td width="20"><font color="white">500W </td>
<td width="20"><font color="white">1K   </td>
<td width="20"><font color="white">2K   </td>

</tr> 

<tr align="center">
<td width="20"> AA quality level</td>
<td width="20">$853 </td>
<td width="20">$916 </td>
<td width="20">$1,221 </td>
<td width="20">$1,045 </td>
</tr> 

<tr align="Center" valign="top" bgcolor= "grey";>


<td width="20">     </td>
<td width="20"><font color="white">3KW </td>
<td width="20"><font color="white">5KW </td>
<td width="20"><font color="white">10KW   </td>
<td width="20"><font color="white">20KW   </td>

</tr> 

<tr align="center">
<td width="20"> AA quality level</td>
<td width="20">$3,291 </td>
<td width="20">$4,528 </td>
<td width="20">$10,812 </td>
<td width="20">$14,044 </td>
</tr> 
I am not sure how about to go about this because I do have about 6 more tables like this and no data base at the moment to store information

What i am trying to do is to have php write the tables and I have a file that I can easily read and make changes to:
lets say I want to change $14,044 to $15,000 with out going through a bunch of code.

Is there a way to make spread sheet and include that information in to the page?

Thanks for any help

Re: Tables from hell

Posted: Sun Aug 01, 2010 3:37 pm
by superdezign
Firstly, why don't you have access to a database?

Secondly, if you want to use a spreadsheet, you'll have to look online to find a solution for translating spreadsheets to HTML. A particular issue would be if you used Microsoft Excel. Easily reading data from Microsoft products requires use of a COM object, which requires a Windows server as far as I know.

Re: Tables from hell

Posted: Sun Aug 01, 2010 3:53 pm
by lang79james
The data base is not set up yet. Next question what about open office spread sheets?
Now it does not have to be a spreed sheet it can be anther file.

Re: Tables from hell

Posted: Sun Aug 01, 2010 3:55 pm
by superdezign
Like I said, you'll have to search the internet for solutions. There's no simple PHP function that can convert files into HTML.

Re: Tables from hell

Posted: Mon Aug 02, 2010 6:36 am
by d8p
You could store the values into a comma separated file (CSV) which I believe is a file type option in MS Excel. So the file looks like value 1, value 2, value 3 etc. You could then read this file and store the values into an array. The use this array to create your table.

Code: Select all

<?php
$filename = ./mycsvfile.txt;
$f = fopen($filename, "r");
$file = fread ($f,filesize ($filename));
fclose ($fd); 

$split = ","; 
$values = explode($split, $file);

echo '<table><tr>';
$i = 0;
while ($i < count($values)) {
echo '<td>$values[$i]</td>';
$i++
}
echo '</tr></table>';
?>
As I said above this code opens the CSV file and reads it's contents. It puts those values into an array and then outputs each value into a row of a table. I hope this helps.