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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.