glenelkins Posted October 27, 2006 Share Posted October 27, 2006 HiFinally 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] Quote Link to comment Share on other sites More sharing options...
glenelkins Posted October 27, 2006 Author Share Posted October 27, 2006 Its actually missing off the first field and shifting the values to the left! The headings display correct though the first field of data is missing...mmm Quote Link to comment Share on other sites More sharing options...
glenelkins Posted October 27, 2006 Author Share Posted October 27, 2006 jesus christ is my error, i labeled the array numbers wrong, i put 5 twice Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.