Forums

Formatting issue problem - Table column widths not working

rcadmin 17 Sep, 2010
My Header is as follows:
<input type='text' name='Name' id='Name' value='' /> <input type='submit'
name='submit' id='submit' value='Filter' />

<table border="0" cellspacing="0" cellpadding="0">
<tr>
    <td width="16" align="center">Name</td>
    <td width="6" align="center">ID</td>
    <td width="6" align="center">Art</td>
    <td width="6" align="center">Dra</td>
    <td width="6" align="center">Mus</td>
    <td width="6" align="center">ESO</td>
    <td width="6" align="center">Num</td>
    <td width="6" align="center">Mao</td>
    <td width="6" align="center">Fre</td>
    <td width="6" align="center">Jap</td>
    <td width="6" align="center">ESO</td>
    <td width="6" align="center">Tec</td>
    <td width="6" align="center">Foo</td>
    <td width="6" align="center">Gra</td>
    <td width="6" align="center">ESO</td>
    <td width="6" align="center">Num</td>
</tr>


Body
<tr>
    <td width="16" align="center">{Name}</td>
    <td width="6" align="center">{Username}</td>
    <td width="6" align="center">{Art}</td>
    <td width="6" align="center">{Drama}</td>
    <td width="6" align="center">{Music}</td>
    <td width="6" align="center">{ESOLa}</td>
    <td width="6" align="center">{Numeracya}</td>
    <td width="6" align="center">{Moari}</td>
    <td width="6" align="center">{French}</td>
    <td width="6" align="center">{Japanese}</td>
    <td width="6" align="center">{ESOLb}</td>
    <td width="6" align="center">{Technology}</td>
    <td width="6" align="center">{FoodTechnology}</td>
    <td width="6" align="center">{Graphics}</td>
    <td width="6" align="center">{ESOLc}</td>
    <td width="6" align="center">{Numeracyc}</td>
</tr>


And footer
</table>
<p> </p>
{pagination}

(Original Post had a cut-and-paste error error 😶 )
Everything works just fine except that the column widths don't change to the specified width. What am I missing:?:
[attachment=0]widths.jpg[/attachment]
GreyHead 17 Sep, 2010
Hi rcadmin,

I'm not sure what you are expecting. That looks about right to me. I just put the code in Dreamweaver and get pretty much the same result. Your headers are actually more than 6 wide so they are getting crunched up.

You'll probably get better control using CSS styles to set the widths.

You only need the width in the header row - that will be picked up in the following rows.

You only need </table> in the footer box, the row won’t do anything much.

Bob
rcadmin 17 Sep, 2010
Oops I had a moment of total confusion...
rcadmin 17 Sep, 2010
One last question about this form.

What code can I put into the header to give me the totals of each of the subject columns?
GreyHead 17 Sep, 2010
Hi rcadmin,

You can probably adapt the code here with a little bit of work. You won't have the totals until the Footer box though.

Bob
rcadmin 18 Sep, 2010
Given that each subject only contains 0 or 1 is it not possible to put something like this into the header:
<?php
// Make a MySQL Connection
mysql_connect("localhost", "admin", "1admin") or die(mysql_error());
mysql_select_db("test") or die(mysql_error());

// Get all the data from the "example" table
$result = mysql_query("SELECT * FROM releventtable") 
or die(mysql_error());  

// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
    $Art=$Art+$Row(Art);
    $Drama=$Drama+$Row(Drama);

.......etc
} 

echo "</table>";
?>


If it is, what code do I use to connect to the database, and how do I convert the $Row(Drama) etc to an integer so that I can add it to $Drama.

In this way I can have the summery in the header and not footer.
Max_admin 20 Sep, 2010
Hi rcadmin,

I suggest you use the Joomla DB class to load the data from the database, then you can use (int) before your string value to use it as integer in PHP like:
$string = '99';
$int = (int)$string; // = 99 now


Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
rcadmin 21 Sep, 2010
Thanks for all your help, it looks and works great now. All I will be changing in future is to make every second line a different background colour and adding a link to download the results as a CSV.

So far the header code looks as follows:
$db =& JFactory::getDBO();
$query = "SELECT * FROM #__chronoforms_form_Year8To9_options;";
$db->setQuery($query);
$result = $db->query();
$row = $db->loadRow();

// keeps getting the next row until there are no more to get
$Total = 0;
while($row = mysql_fetch_array( $result )) {
   $Total = $Total + 1;
   $Art=$Art+$row[Art];
   $Drama=$Drama+$row[Drama];
   $Music=$Music+$row[Music];
   $ESOLa=$ESOLa+$row[ESOLa];
   $Numeracya=$Numeracya+$row[Numeracya];
   $Moari=$Moari+$row[Moari];
   $French=$French+$row[French];
   $Japanese=$Japanese+$row[Japanese];
   $ESOLb=$ESOLb+$row[ESOLb];
   $Literacy=$Literacy+$row[Literacy];
   $Numeracyb=$Numeracyb+$row[Numeracyb];
   $Technology=$Technology+$row[Technology];
   $FoodTechnology=$FoodTechnology+$row[FoodTechnology];
   $Graphics=$Graphics+$row[Graphics];
   $ESOLc=$ESOLc+$row[ESOLc];
   $Numeracyc=$Numeracyc+$row[Numeracyc];
} 
?>
<input type='text' name='Name' id='Name' value='' /> <input type='submit'
name='submit' id='submit' value='Filter' class="filter"/>
<p> </p>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
    <td width="104"><strong>Totals</strong></td>
    <td width="40" align="center"></td>
    <td width="28" align="center"><strong>Art</strong></td>
    <td width="28" align="center"><strong>Dra</strong></td>
    <td width="28" align="center"><strong>Mus</strong></td>
    <td width="28" align="center"><strong>ESO</strong></td>
    <td width="28" align="center"><strong>Num</strong></td>
    <td width="28" align="center"><strong>Mao</strong></td>
    <td width="28" align="center"><strong>Fre</strong></td>
    <td width="28" align="center"><strong>Jap</strong></td>
    <td width="28" align="center"><strong>ESO</strong></td>
    <td width="28" align="center"><strong>Lit</strong></td>
    <td width="28" align="center"><strong>Num</strong></td>
    <td width="28" align="center"><strong>Tec</strong></td>
    <td width="28" align="center"><strong>Foo</strong></td>
    <td width="28" align="center"><strong>Gra</strong></td>
    <td width="28" align="center"><strong>ESO</strong></td>
    <td width="28" align="center"><strong>Num</strong></td>
</tr>
 <tr>
    <td colspan="18"><hr></td>
  </tr>
<tr>
    <td><?=$Total?></td>
    <td align="center"></td>
    <td align="center"><?=$Art?></td>
    <td align="center"><?=$Drama?></td>
    <td align="center"><?=$Music?></td>
    <td align="center"><?=$ESOLa?></td>
    <td align="center"><?=$Numeracya?></td>
    <td align="center"><?=$Moari?></td>
    <td align="center"><?=$French?></td>
    <td align="center"><?=$Japanese?></td>
    <td align="center"><?=$ESOLb?></td>
    <td align="center"><?=$Literacy?></td>
    <td align="center"><?=$Numeracyb?></td>
    <td align="center"><?=$Technology?></td>
    <td align="center"><?=$FoodTechnology?></td>
    <td align="center"><?=$Graphics?></td>
    <td align="center"><?=$ESOLc?></td>
    <td align="center"><?=$Numeracyc?></td>
</tr>
</table>
<p> </p>

<table border="0" cellspacing="0" cellpadding="0">
<tr>
    <td width="104"><strong>Name</strong></td>
    <td width="40" align="center"><strong>ID</strong></td>
    <td width="28" align="center"><strong>Art</strong></td>
    <td width="28" align="center"><strong>Dra</strong></td>
    <td width="28" align="center"><strong>Mus</strong></td>
    <td width="28" align="center"><strong>ESO</strong></td>
    <td width="28" align="center"><strong>Num</strong></td>
    <td width="28" align="center"><strong>Mao</strong></td>
    <td width="28" align="center"><strong>Fre</strong></td>
    <td width="28" align="center"><strong>Jap</strong></td>
    <td width="28" align="center"><strong>ESO</strong></td>
    <td width="28" align="center"><strong>Lit</strong></td>
    <td width="28" align="center"><strong>Num</strong></td>
    <td width="28" align="center"><strong>Tec</strong></td>
    <td width="28" align="center"><strong>Foo</strong></td>
    <td width="28" align="center"><strong>Gra</strong></td>
    <td width="28" align="center"><strong>ESO</strong></td>
    <td width="28" align="center"><strong>Num</strong></td>
</tr>
 <tr>
    <td colspan="18"><hr></td>
  </tr>

[attachment=0]results.jpg[/attachment]
This topic is locked and no more replies can be posted.