i have to creat a form to generate a report that give details about the usage of stock of my system. there are 4 conditions to generate the report, and user are given a choice to select all 4 condition, or any of the four and also user can choose not to select anything and it will generate the report based pn the condition selected by user. the conditions are year, month, software name and company name.
i'm having a problem to create a paging on the report, i need to have a paging to made it look more organized if the data are to much.
ok here is the code that made the paging unsuccessful, can anyone take a look at it and give me some idea...
--------------------------------------------------------------------------------------
<?php
include("dbconn.php");
session_start();
if($_SESSION['link_id2'] != '')
{
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>WELCOME TO SOFTWARE TRACKING SYSTEM: LOGIN </title>
<meta http-equiv="Content-Language" content="English" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="BlueFresh/style.css" media="screen" />
<style type="text/css">
<!--
.style4 {font-family: "Times New Roman", Times, serif}
.style5 {font-size: small}
.style6 {font-family: "Times New Roman", Times, serif; font-size: small; }
-->
</style>
<script language="JavaScript" src="_js/date_picker.js"></script>
<script language="JavaScript" src="_js/overlib_mini.js"></script>
<script src = "_js/getStockTotal.js"></script><br />
<script type="text/javascript" src="_js/mootools.js"></script>
<script type="text/javascript" src="_js/changeToUpperCase-company.js"></script>
<script language='Javascript'>
/* function popwin(urla)
{
window.open(urla,'add','height=600,width=764,left=0,top=0,resizable=no,scrollbars=yes,toolbar=no,status=no');
//if (window.focus) {newwindow.focus()}
}*/
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.style1 {font-family: Georgia, "Times New Roman", Times, serif; }
.style2 {font-family: Georgia, "Times New Roman", Times, serif; color: #EEEEEE}
-->
</style>
</head>
<body>
<?php
if(isset($_POST['Submit'])){
include("dbconn.php");
$year = $_POST['year'];
$start = $_POST['start'];
$end = $_POST['end'];
$software_name = $_POST['software_name'];
$company_name = $_POST['company_name'];
$s="";$sq="";$sqq=""; $sqqq="";
$PCK=0;$pk="bobo";
if($year == "none")
$s="";
else
{$pk="baba";
if($PCK==0)
$s=" WHERE YEAR(s.software_request_date) = '$year'";
else
$s=" AND YEAR(s.software_request_date) = '$year'";
$PCK++;
}
if($start=="" && $end=="" )
$sqq="";
else
{
if($PCK==0)
{$sqq=" WHERE s.software_request_date BETWEEN '$start' AND '$end'";}
else
$sqq=" AND s.software_request_date BETWEEN '$start' AND '$end'";
$PCK++;
}
if($software_name=="none")
$sqq="";
else
{
$pk="baba";
if($PCK==0)
{$sqq=" WHERE s.software_name = '$software_name'";}
else
$sqq=" AND s.software_name='$software_name'";
$PCK++;
}
if($company_name=="none")
$sqqq="";
else
{
$pk="baba";
if($PCK==0)
{$sqqq=" WHERE co.company_name='$company_name'";}
else
$sqqq=" AND co.company_name='$company_name'";
$PCK++;
}
$sql = "SELECT *
FROM table_software so
INNER JOIN table_software_purchased_record s
ON so.software_name=s.software_name
INNER JOIN table_client c
ON s.client_id=c.client_id
INNER JOIN table_company co
ON c.company_id=co.company_id".$s.$sq.$sqq.$sqqq;
$num = 1;
$query = mysql_query($sql) or die("Error: " . mysql_error());
$row = mysql_num_rows($query);
$row;
$numbe=$row;
while($numbe%20!=0)
$numbe++;
if(isset($_GET['page']))
$pg=$_GET['page'];
else
$pg=1;
$numbe1=1;
if($row != 0){
$data = mysql_fetch_assoc($query);
echo "<table width=\"1115\" align=\"center\" border=\"0\">";
echo "<tr>";
echo "<td colspan=\"4\" align=\"center\">"; //5 -> 4
echo "<b> year: </b>" . $year . "</td>";
echo "</tr>";
echo "<td colspan=\"4\" align=\"center\">"; //5 -> 4
echo "<b> dates: </b>" . $start . " - ". $end. "</td>";
echo "</tr>";
echo "<td colspan=\"4\" align=\"center\">"; //5 -> 4
echo "<b> software name: </b>" . $software_name. "</td>";
echo "</tr>";
echo "<td colspan=\"4\" align=\"center\">"; //5 -> 4
echo "<b> company name: </b>" . $company_name. "</td>";
echo "</tr>";
echo "<tr>";
echo "<td colspan=\"4\" align=\"right\">"; //5 -> 4
echo "<b>download: </b>
<a href=\"pdf2.php?search_code=$search_code\">
<img src=\"image/pdf_button.png\" alt=\"PDF\" width=\"16\" height=\"16\" /></a>
</td>
</tr>
</table>";
?>
<form name="form1" method="post" action="#.php">
<p> </p>
<p> </p>
<table width="1200" border="1" align="center">
<tr>
<td width="23"><div align="center" class="style17 style23 style25">No</div></td>
<td width="119"><div align="center" class="style17 style23 style25">Date </div></td>
<td width="393"><div align="center" class="style17 style23 style25">Company's Name </div></td>
<td width="223"><div align="center" class="style17 style23 style25">Client's Name </div></td>
<td width="233"><div align="center" class="style17 style23 style25">Software's Name </div></td>
<td width="71"><div align="center" class="style17 style23 style25">Units </div></td>
<td width="138"><div align="center" class="style17 style23 style25">Form Number </div></td>
</tr>
<?php
while($row= mysql_fetch_assoc($query)){
if($numbe1>(($pg-1)*20) && $numbe1<=($pg*20))
{
?>
<tr>
<td align="center" class="style1"><?php echo $numbe1; ?></td>
<td align="center" class="style1"><?php echo $row['software_request_date']; ?></td>
<td align="center" class="style1"><?php echo $row['company_name']; ?></td>
<td align="center" class="style1"><?php echo $row['client_name']; ?></td>
<td align="center" class="style1"><?php echo $row['software_name'];?></td>
<td align="center" class="style1"><?php echo $row['software_quantity'];?></td>
<td><div align="center"><a href="history_detail.php?form_number=<?php echo $row['form_number']; ?>"><?php echo $row['form_number']; ?> </a> </div></td>
<?php
} $numbe1++; $num++; //tutup if
}
} ?> </tr></table>
<table align="center"><tr><td>Page </td>
--------------------------------------------------------------------------------------
this is where the problem that make me stuck with it for about 3 weeks...please take a look...
<?php
for($w7=1;$w7<=($numbe/20);$w7++)
echo "<td><a href='paging9.php?page=".$w7."&year=".$year. "&start=".$start. "&end=".$end."&software_name=".$software_name."&company_name=".$company_name."'>".$w7."</a></td>";echo "<td><font color='#ffcc66'>Current page = ".$pg."</font></td>";
?>
--------------------------------------------------------------------------------------
</tr></table>
</form>
<?php
}
?>
</body>
</html>
<?php
}
else
{
header("Location: user_login.php?") ;
}
?>
i'm having a problem in creating the correct sql for the paging. so it's stuck there, when i click link to page 1, it will go to a blank page... can anyone help me please?