Jump to content

Again With The Table Generation


glenelkins

Recommended Posts

Hi

Finally got the table generation to work...though its having a problem!. When it comes to the last column it does not seem to display the database information ($this->equ_info[$count][10] = $r['insulating_name'])

Here is the info array script:
[code]
function DisplayEQUInfo ($id) {
  if (!($result = $this->DbQuery("SELECT * FROM equipment WHERE site_id='$id'"))) {
    $this->ShowError("Error Selecting Equipment Information");
  }

  $count=0;
  while ($r = mysql_fetch_array($result)) {
    $this->equ_info[$count][0] = $r['type'];
    $this->equ_info[$count][1] = $r['serial'];
    $this->equ_info[$count][2] = $r['manufacturer'];
    $this->equ_info[$count][3] = $r['country_of_origin'];
    $this->equ_info[$count][4] = $r['power_rating'];
    $this->equ_info[$count][5] = $r['voltage'];
    $this->equ_info[$count][5] = $this->FormatDate($r['date_of_fabrication']);
    $this->equ_info[$count][6] = $r['weight'];
    $this->equ_info[$count][7] = $r['oil_liquid'];
    $this->equ_info[$count][8] = $r['total_weight'];
    $this->equ_info[$count][9] = $r['size'];
    $this->equ_info[$count][10] = $r['insulating_name'];

    $count++;
  }

  $arr = array (
    'direction' => 'vert',
    'field_headings' => array ("Type (Transformer,Capacitor etc)","Serial Number","Manufacturer","Country Of Origin","Power Rating(w)","Voltage(in/out)(V)","Date Of Fabrication","Dry Weight (Kg)","Oil/Liquid (l or Kg)","Total Weight (Kg)","Size (L/W/H)","Name Of Liquid Or Insualating Oil/Coolant etc"),
    'field_contents' => array ($this->equ_info)
  );

  $display .= $this->CreateTableDisplay($arr);

  return $display;
}
[/code]

And Here Is The table generation
[code]
function CreateTableDisplay ($arr) {

if ($arr['direction'] == 'vert') {
$table = "<table border='0' align='center'>
<tr>";

foreach ($arr['field_headings'] as $fh) {
$table .= "
<td align='center'>
<b>" . $fh . "</b>
</td>";
}

$table .= "</tr>";

foreach ($arr['field_contents'][0] as $fc){
$table .= "<tr>";
foreach ($fc as $value) {
$table .= "
<td align='center'>
" . $value . "
</td>";
}
$table .= "</tr>";
}

$table .= "</tr></table>";
}elseif($arr['direction'] == 'horiz') {
$table = "<table border='0' align='center'>";

$count=0;
foreach ($arr['field_headings'] as $fh) {
$table .= "
<tr>
<td width='50%'>
<b>" . $fh . "</b>
</td>
<td width='50%'>
" . $arr['field_contents'][0][0][$count] . "
</td>
</tr>";
$count++;
}

$table .= "</table>";
}

return $table;
}
[/code]
Link to comment
https://forums.phpfreaks.com/topic/25288-again-with-the-table-generation/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.