Jump to content

post function


scarezekiel

Recommended Posts

im new..so i need your help. hard for me to explain so i just attached a photo how I need it to be..

 

 

this is the view


<div class="view">

<?php

	$con = mysql_connect("","root","");
    mysql_select_db('', $con);
    
$this->beginWidget('zii.widgets.jui.CJuiDialog', array(
    'id'=>$data->id,
    // additional javascript options for the dialog plugin
    'options'=>array(
        'title'=>'Report (Other)',
        'autoOpen'=>false,
	'modal'=>true,
'resizable' =>false,
    ),
));

echo "<form action=\"report/$data->name.php\" name=\"selection\" method=\"post\"  target=\"_blank\">";
echo "<b><font style=\"font-size:12px; \">$data->name <br><br>";

if (($data->haslocation) == 1)
{
    $sql="SELECT * FROM tbllocation";
    $result = mysql_query($sql,$con);
echo "Location : ";
    echo "<select name=location value=''>location</option>";
    echo "<option value=0></option>";
    
    while ($row=mysql_fetch_array($result)) { 
$id=$row["id"]; 
    $code=$row["code"]; 
    $description=$row["description"]; 
    echo "<option value=$id>$description </option>";
} 
echo "</select>";
echo "<br><br>";
}

if (($data->hasdistrict) == 1)
{
    $sql="SELECT * FROM tbldistrict";
    $result = mysql_query($sql,$con);
echo "District : ";
    echo "<select name=\"district\" >district</option>";
    echo "<option value=0></option>";
    
    while ($row=mysql_fetch_array($result)) { 
$id=$row["id"]; 
    $code=$row["code"]; 
    $description=$row["description"]; 
    echo "<option value=$id>$description </option>";
} 
echo "</select>";
echo "</font><br><br>";
}




echo "<input type=\"submit\" value=\"Preview\" style=\"font-size:12px;font-family:verdana; \"/>";

echo "</form>";


$this->endWidget('zii.widgets.jui.CJuiDialog');

// the link that may open the dialog
//<img src="themes\shadow_dancer\images\small_icons\preview.png" width="4%"></img>
echo CHtml::link('', '#', array(
   'onclick'=>'$("#'.$data->id.'").dialog("open"); return false;',
));
?>
 

<?php echo CHtml::link($data->name, '#', array(
   'onclick'=>'$("#'.$data->id.'").dialog("open"); return false;',
)); ?>
</div>

 

 

 

 

and this is the report page

 



<?php require("html2fpdf.php"); 

$server = '';
$username = '';
$password = '';
$database_name='';

$dbconn = mysql_connect($server, $username,$password,false) or die("Could not establish connection");

mysql_select_db($database_name, $dbconn) or die ("Could not select database");

if (!$dbconn) {
    die('Something went wrong while connecting to MSSQL');
}


ob_start(); ?>




<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
  <meta content="text/html; charset=ISO-8859-1"
http-equiv="content-type">
  <title></title>
  <h5 align="center"><U>KRETAM HOLDINGS BERHAD (168285-H)</U></h5>
  
</head>
<body>
<table style="text-align: left; width: 715px; height: 32px;"
border="1" cellpadding="2" cellspacing="2">
  <tbody>
    <tr>
      <th align="left" colspan="2" rowspan="1"
style="font-style: italic;">List-Field</th>
    </tr>
    <tr>
      <th style="font-style: italic;">Field No</th>
      <th style="font-style: italic;">Ex Field No</th>
      <th style="font-style: italic;">Type</th>
      <th style="font-style: italic;">Planting Year</th>
      <th style="font-style: italic;">Statement Year</th>
      <th style="font-style: italic;">Field Hectares</th>
      <th style="font-style: italic;">Total Hectares</th>
      <br />      
    </tr>
    

<?

$query="SELECT * FROM tblfield
        ORDER BY statementyear, type desc, plantingyear";
        $result=mysql_query($query);
$grandtotalhec=0;
while($row=mysql_fetch_array($result)) {
    echo $_POST["selection"]; 
$fieldno = $row['fieldno'];
$exfieldno = $row['exfieldno'];
    $type = $row['type'];
    $plantingyear = $row['plantingyear'];
    $statementyear = $row['statementyear'];
    $fieldhectares = $row['fieldhectares'];
    $totalhectares = $row['totalhectares'];
echo "<tr><td align='center'>$fieldno</td>";
echo "<td align='center'>$exfieldno</td></tr>";
echo "<td align='center'>$type</td></tr>";
echo "<td align='center'>$plantingyear</td></tr>";
echo "<td align='center'>$statementyear</td></tr>";
echo "<td align='center'>$fieldhectares</td></tr>";
echo "<td align='center'>$totalhectares</td></tr>";
$grandtotalhec = $grandtotalhec + $fieldhectares;
}
echo "<tr>";
        echo "<td></td>";
        echo "<td></td>";	
        echo "<td></td>";		
        echo "<td></td>";	
        echo "<td></td>";	
        echo "<td></td>";			
	echo "<td align='center' colspan=9>".$grandtotalhec."</td>";
echo "</tr>";	
?>



</tbody>
</table>
<table style="text-align: left; width: 715px; height: 32px;"
border="1" cellpadding="2" cellspacing="2">
</tbody>
<tr>
      <th align="left" colspan="1" rowspan="1"
style="font-style: italic;">List-Land Utilities</th>
    </tr>
    <tr>
      <th align="left" style="font-style: italic;">Description</th>
      <th style="font-style: italic;">Location ID</th>
      <th style="font-style: italic;">Statement Year</th>
      <th style="font-style: italic;">Land Hectares</th>   
      <th style="font-style: italic;">Total Hectares</th>     
    </tr>

<?
$query="SELECT * FROM tbllandutilities";
        $result=mysql_query($query);
       	$grandtotallandhec=0;
while($row=mysql_fetch_array($result)) { 
$description = $row['description'];
       $locationid = $row['locationid'];
        $statementyear = $row['statementyear'];
$landhectares = $row['landhectares']; 
    $totalhectares = $row['totalhectares'];  
echo "<tr><td>$description</td>";
echo "<td align='center'>$locationid</td></tr>";
echo "<td align='center'>$statementyear</td></tr>";
echo "<td align='center'>$landhectares</td></tr>";
echo "<td>$totalhectares</td></tr>";
}
?>
  </tbody>
</table>
<br>
</body>
</html>




<?php $var = ob_get_clean(); 


$pdf = new HTML2FPDF('P', 'mm', 'Letter'); 
		$pdf->AddPage(); 
		$pdf->WriteHTML($var); 
		$pdf->Output('test.pdf', 'I');

?>

 

 

so basically i need it to show in order by the statementyear..

 

another statementyear, another page..

 

 

perhaps anyone can show me how to amend my codes.

post-131669-13482403588914_thumb.jpg

Link to comment
https://forums.phpfreaks.com/topic/264034-post-function/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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