Jump to content


Photo

Again With The Table Generation


  • Please log in to reply
2 replies to this topic

#1 glenelkins

glenelkins
  • Members
  • PipPipPip
  • Advanced Member
  • 760 posts
  • LocationBridlington - East Riding of Yorkshire - United Kingdom

Posted 27 October 2006 - 09:42 AM

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:
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;
}

And Here Is The table generation
	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;
	}

http://thewebsolutionprovider.com - A Solution For Everything Web!

#2 glenelkins

glenelkins
  • Members
  • PipPipPip
  • Advanced Member
  • 760 posts
  • LocationBridlington - East Riding of Yorkshire - United Kingdom

Posted 27 October 2006 - 10:12 AM

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
http://thewebsolutionprovider.com - A Solution For Everything Web!

#3 glenelkins

glenelkins
  • Members
  • PipPipPip
  • Advanced Member
  • 760 posts
  • LocationBridlington - East Riding of Yorkshire - United Kingdom

Posted 27 October 2006 - 10:13 AM

jesus christ is my error, i labeled the array numbers wrong, i put 5 twice
http://thewebsolutionprovider.com - A Solution For Everything Web!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users