<?php
include 'session.inc';
check_login();
$con=mysql_connect("localhost","root","");
if(!$con)
die('Could not connect:' .mysql_error());
mysql_select_db("vms", $con);
if($_POST[product]!='NONE')
{
$product=$_POST[product];
}
else
{
$product='NONE';
}
$expire=time()+60*60;
setcookie("product",$product,$expire);
if(product!='NONE')
{
// how many rows to show per page
$rowsPerPage = 20;
// by default we show first page
$pageNum = 1;
// if $_POST['page'] defined, use it as page number
if(isset($_POST['page']))
{
echo "page:".$_POST['page'];
$pageNum = $_POST['page'];
}
// counting the offset
$offset = ($pageNum - 1) * $rowsPerPage;
$query="SELECT CRNo AS CR,DescriptionCR AS DCR FROM cr where Product='".$product."' ORDER BY CR"." . LIMIT $offset, $rowsPerPage";
$result = mysql_query($query);
$i=0;
$TotalNoOfCR=0;
$checkcr=0;
while($row = mysql_fetch_array($result))
{
$CR[$i]=$row['CR'];
$row['DCR']=str_replace("\'","'",$row['DCR']);
$DCR[$i]=$row['DCR'];
$TotalNoOfCR=$i;
$checkcr=1;
$i++;
}
$query="SELECT CRNo AS CR,DescriptionCR AS DCR FROM cr where Product='".$product."' ORDER BY CR".";
$result = mysql_query($query);
$i=0;
$numrows=0;
while($row = mysql_fetch_array($result))
{
$numrows=$i;
$i++;
}
$maxPage = ceil($numrows/$rowsPerPage);
// print the link to access each page
$self='Upd_provsCRform.php';
$nav ='';
for($page = 1; $page <= $maxPage; $page++)
{
if ($page == $pageNum)
$nav .= "$page" ; // [QUOTE]getting error on this line [/QUOTE]no need to create a link to current page
else
$nav .="<a href=\"$self?page=$page\">$page</a>";
}
// creating previous and next link
// plus the link to go straight to
// the first and last page
if ($pageNum > 1)
{
$page = $pageNum - 1;
$prev = " <a href=\"$self?page=$page\">[Prev]</a> ";
$first = " <a href=\"$self?page=1\">[First Page]</a> ";
}
else
{
$prev = ' '; // we're on page one, don't print previous link
$first = ' '; // nor the first page link
}
if ($pageNum < $maxPage)
{
$page = $pageNum + 1;
$next = " <a href=\"$self?page=$page\">[Next]</a> ";
$last = " <a href=\"$self?page=$maxPage\">[Last Page]</a> ";
}
else
{
$next = ' '; // we're on the last page, don't print next link
$last = ' '; // nor the last page link
}
// print the navigation link
echo $first . $prev . $nav . $next . $last;
// and close the database connection*/
mysql_close($con);
}
$query="SELECT projectName AS project FROM project_details ORDER BY project";
$result = mysql_query($query);
$i=0;
$TotalNoOfProject=0;
while($row = mysql_fetch_array($result))
{
$PR[$i]=$row['project'];
$TotalNoOfProject=$i;
$i++;
}
$query="SELECT status as S,shortstatus as SS FROM cr_status";
$result = mysql_query($query);
$i=0;
$TotalNoOfStatus=0;
while($row = mysql_fetch_array($result))
{
$status[$i]=$row['S'];
$shortstatus[$i]=$row['SS'];
$TotalNoOfStatus=$i;
$i++;
}
?>
kingfheartz 0 Newbie Poster
urtrivedi 276 Nearly a Posting Virtuoso
kingfheartz 0 Newbie Poster
urtrivedi 276 Nearly a Posting Virtuoso
kingfheartz 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.