Data report display horizontally

General discussions related to php

Moderators: egami, macek, gesf

Post Reply
User avatar
jayson2012
New php-forum User
New php-forum User
Posts: 5
Joined: Wed Aug 09, 2017 7:52 pm

Wed Aug 09, 2017 8:08 pm

Hi Coders,

anyone can help me with the following output, Image

<img src='https://i.imgur.com/cFwgY2y.jpg' />

chorn
php-forum Active User
php-forum Active User
Posts: 402
Joined: Fri Apr 01, 2016 2:18 am

Wed Aug 09, 2017 10:33 pm

how should we help with what your fingers output?

User avatar
jayson2012
New php-forum User
New php-forum User
Posts: 5
Joined: Wed Aug 09, 2017 7:52 pm

Wed Aug 09, 2017 11:11 pm

i have, a table like what you saw above, and i want to display it in HTML table like above.
hope you understand, thank you.

chorn
php-forum Active User
php-forum Active User
Posts: 402
Joined: Fri Apr 01, 2016 2:18 am

Thu Aug 10, 2017 12:54 am

Code: Select all

<table>
<tr>
<td><img src='https://i.imgur.com/cFwgY2y.jpg' /></td>
</tr>
</table>

User avatar
jayson2012
New php-forum User
New php-forum User
Posts: 5
Joined: Wed Aug 09, 2017 7:52 pm

Thu Aug 10, 2017 1:59 am

No, what i mean i a query.

i have here, i did not get the right output

Code: Select all

public function load_report()
			{
				
				$this->db->select('com.comid,com.cid,com.sid,com.uid,com.branch,com.aqty,com.adate,com.temp');
				$this->db->select('co.cid,co.description,co.bqty,co.uid,co.temp');
				$this->db->select('b.area_code,b.branch_name');
				$this->db->select('s.stock_id,s.Barcode,s.description');
				$this->db->from('pt_compiled as com');
				
				$this->db->join('pt_compile as co','com.cid = co.cid','left');
				$this->db->join('branches as b','com.branch = b.area_code','left');
				$this->db->join('stocks as s','co.description = s.description','left');
				
				$this->db->group_by('com.cid');
				$result = $this->db->get();
				return $result->result_array();
			}

Code: Select all

<tr class="danger">
				
				<th class="text-center" style="padding-top:14px">Description</th>
				<th class="text-center" style="padding-top:14px">Quantity</th>
				<?php foreach($result_branch as $row) {?>
				<th><?php echo $row['branch_name']; ?></th>
				<?php  }  ?>
			</tr>
			<?php foreach($result_branch as $row) { ?>
			<tr>
				<td class="text-center"><input type="checkbox" class="case" name="checked[]" value = "<?php echo $row['cid']; ?>"/></td>
	
				
				<td><?php echo $row['description']; ?></td>
				<td><?php echo $row['bqty']; ?></td>
				<?php foreach($result_quantity as $row) {?>	
				<td><?php echo $row['aqty']; ?></td>
				<?php } ?>
</tr>
output
the cross red was i neeed to set as 0, but i don't have an idea how. please help
Image

chorn
php-forum Active User
php-forum Active User
Posts: 402
Joined: Fri Apr 01, 2016 2:18 am

Thu Aug 10, 2017 10:58 pm

post an comprehensible example with data.

User avatar
jayson2012
New php-forum User
New php-forum User
Posts: 5
Joined: Wed Aug 09, 2017 7:52 pm

Fri Aug 11, 2017 5:20 pm

thanks for your response, so lets focus in one table, and don't mind the source code i posted above, and here is sample image what i want to be.

it looks like a pivot, but i need in HTML table combination it means, its combine with php loop

and i hope it will give you clarification.
Image

Thanks,

User avatar
jayson2012
New php-forum User
New php-forum User
Posts: 5
Joined: Wed Aug 09, 2017 7:52 pm

Sun Aug 13, 2017 10:36 pm

here is my solution, hope it will help you guys

Code: Select all

$empty = array();
foreach($result_cid as $row) {
		$empty[$row['branch']] = '&nbsp;';
			}
			echo "<table class='table table-hover table-bordered'>
				<tr><th class='text-center'>Descriptions</th><th>";
			$heads = array_keys($empty);
			echo join ('</th><th class="text-center">', $heads)  . "</th></tr>\n";

			$prevr = '';
		foreach($load_report_branch as $list)
				{
					$r = $list['description'];
					$c = $list['branch'];
					$n = $list['aqty'];
				$lastr;
				if ($lastr != $r) 
					{
						if ($lastr != '') 
							{
								echo "<tr><th>$lastr</th><td>";
								echo join('</td><td class="text-center">', $rowdata) . "</td></tr>\n";
							}
						$rowdata = $empty;
						$lastr = $r;
					}
					$rowdata[$c]  = $n;
				}
		echo "<tr><th>$lastr</th><td>";
		echo join('</td><td class="text-center">', $rowdata) . "</td></tr>\n";
		echo "</table>\n";

Post Reply