Jump to content

How to make row and column to be dynamic


fansa

Recommended Posts

don't entirely understand what you want?

 

actually i want to make like this

Y YYYYYYYYY

x d d d d d d d

x d d d d d d d

x d d d d d d d

x d d d d d d d

 

Y-is dynamic.meB will be more and meB will be only one column it based on data(d)

x-also dynamic.meB will be more and meB will be only one row it based on data(d)

 

the coading that i have done is like below..but the success is only be the row dynamic not the column...can u all help me???

 

<?php

session_start();

if(session_is_registered('username') && session_is_registered('level')&& session_is_registered('cust_id'))

{

  //get connection to database

  include('../connect.php');

//declare array

$group_category=array();

$group_location=array();

 

 

$sql_1 = "select company_name from fls_customer where customer_id = '".$_SESSION['cust_id']."'";

$result1 = mysql_query($sql_1, $link);

$rows1=mysql_fetch_array($result1);

$com_name = $rows1['company_name'];

 

if ($_REQUEST["mula"] != '00-00-0000'){

$startDate=$_REQUEST["mula"];

$split = explode("-", $startDate);

$mula = "" . $split[2] . "-" . $split[1] . "-" . $split[0];

}

 

if ($_REQUEST["tamat"] != '00-00-0000'){

$endDate=$_REQUEST["tamat"];

$split = explode("-", $endDate);

$tamat = "" . $split[2] . "-" . $split[1] . "-" . $split[0];

}

 

//$field1="location"; $field2="company_name"; $field3="$mula"; $field4="report_date";

$table1="fls_faultreport "; $table2="fls_product_category ";

$order="location asc";

 

if ($_REQUEST["locate"] != 'all') { $location=" and $table1.location='".$_REQUEST["locate"]."'"; }

else { $location= ""; }

 

 

 

 

if ($com_name == 'Suruhanjaya Syarikat Malaysia (SSM)')

{

$oncategory= "$table1.category = $table2.category";

 

}

elseif ($com_name != 'Suruhanjaya Syarikat Malaysia (SSM)')

{

$oncategory= "$table1.category = $table2.cat_id";

 

}?>

<? echo "SELECT $table2.category,$table1.location

FROM $table1

INNER JOIN $table2

ON $oncategory

WHERE $table1.report_date between '$mula' and '$tamat' $location

group by $table2.category

ORDER BY $table1.$order ";

  $sqlselect=mysql_query("SELECT $table2.category,$table1.location

FROM $table1

INNER JOIN $table2

ON $oncategory

WHERE $table1.report_date between '$mula' and '$tamat' $location

group by $table2.category

ORDER BY $table1.$order ",$link);

 

$j=0;

while(list($cat,$loc) = mysql_fetch_row($sqlselect))

{

 

$group_category[$j]=$cat;

$group_location[$j]=$loc;?>

 

<table>

<tr>

<td><strong><span class="style35"><?php echo $group_location[$j];?></span></strong></td>

</tr>

</table>

<? $j++; }?>

 

 

<?php

} // end session

?>

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.