0

Notice: Undefined index: txtKeyword1 em paginação

criado por Wellington em 13/04/2016 7:11pm
Erro paginação com php e banco de dados Access.

<html>
<head>
<title>ThaiCreate.Com PHP & COM (ADO)</title>
</head>
<body>

<form name="frmSearch" method="get" action="<?php echo $_SERVER['SCRIPT_NAME'];?>">
<!-- <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="get"> -->
<table width="599" border="1">
<tr>
<th>Keyword
<input name="txtKeyword1" type="text" id="txtKeyword1">
<input name="txtKeyword2" type="text" id="txtKeyword2"> <!--//value="<?php echo $_GET["txtKeyword"];?>"> -->
<input type="submit" value="Search"></th>
</tr>
</table>
</form>
<?php
session_start();
include("c:/hosttar/www/root/config.php");

$intID='';
$No='';
$PageNo='';
$Page='';

if(!isset($_GET["txtKeyword1"]))
{
$strKeyword1=$_GET["txtKeyword1"];
}else
{
if(!isset($_GET["txtKeyword2"]))
{
$strKeyword2=$_GET["txtKeyword2"];
}else{
$strKeyword1 = $_GET['txtKeyword1'];
$strKeyword2 = $_GET['txtKeyword2'];

$strSQL = "SELECT * FROM chamsai WHERE (data between #$strKeyword1# And #$strKeyword2#) ORDER by ramal ASC";
//$strSQL = "SELECT * FROM chamsai WHERE (data between #14/11/2007# And #16/11/2007#)"; //Line OK
$objRec = new COM("ADODB.Recordset");
$objRec->Open($strSQL, $conn, 1, 3);
if($objRec->EOF)
{
echo "Not found Record.";
}
else
{
$PageLen = 20;
$PageNo = $_GET["Page"];
if(!$PageNo)
{
$PageNo = 1;
}
$TotalRecord = $objRec->RecordCount();
$objRec->PageSize = $PageLen;
$TotalPage = $objRec->PageCount();
$objRec->AbsolutePage = $PageNo;
?>
<table width="600" border="1">
<tr>
<th width="91"> <div align="center">Ramal </div></th>
<th width="98"> <div align="center">Data </div></th>
<th width="198"> <div align="center">Telefone </div></th>
<th width="97"> <div align="center">Hora </div></th>
<th width="59"> <div align="center">Duracao </div></th>
<th width="71"> <div align="center">Custo </div></th>
</tr>
<?php
While (!($objRec->EOF) and $No < $PageLen)
{
?>
<tr>
<td><div align="center"><?php echo $objRec->Fields["ramal"]->Value;?></div></td>
<td><?php echo $objRec->Fields["data"]->Value;?></td>
<td><?php echo $objRec->Fields["telefone"]->Value;?></td>
<td><div align="center"><?php echo $objRec->Fields["hora"]->Value;?></div></td>
<td align="right"><?php echo $objRec->Fields["duracao"]->Value;?></td>
<td align="right"><?php echo $objRec->Fields["custo"]->Value;?></td>
</tr>
<?php
$No = $No + 1;
$objRec->MoveNext();
}

?>
</table>
<?php
}
$objRec->Close();
$conn->Close();
$conn = null;
?>

Total : <?php echo $TotalRecord?> Page <?php echo $PageNo?> All Page <?php echo $TotalPage?>
<?php if($PageNo > 1){ ?>
<a href="<?php echo $_SERVER['SCRIPT_NAME'];?>?txtKeyword=<?php echo $strKeyword;?>&Page=1"><< Inicio</a>
<a href="<?php echo $_SERVER['SCRIPT_NAME'];?>?txtKeyword=<?php echo $strKeyword;?>&Page=<?php echo $PageNo-1?>">< Anterior</a>
<?php }?>
<?php if($PageNo < $TotalPage) { ?>
<a href="<?php echo $_SERVER['SCRIPT_NAME'];?>?txtKeyword=<?php echo $strKeyword1,$strKeyword2;?>&Page=<?php echo $PageNo+1?>">Proxima ></a>
<a href="<?php echo $_SERVER['SCRIPT_NAME'];?>?txtKeyword=<?php echo $strKeyword;?>&Page=<?php echo $TotalPage?>">Ultima >></a>
<?php }?>
<br>
Ir Para
<?php for($intID=1;$intID<=$TotalPage;$intID++){?>
<?php if($intID == $PageNo){?>
<?php echo $intID?>
<?php }else{?>
<a href="<?php echo $_SERVER['SCRIPT_NAME'];?>?txtKeyword=<?php echo $strKeyword;?>&Page=<?php echo $intID?>"><?php echo $intID?></a>
<?php }?>
<?php }?>
<?php }?>
<?php }?>
</body>
</html>

Lista de Respostas:

Nenhuma resposta foi publicada ainda.

Nova Resposta:

(Você pode usar tags como <b>, <i> ou <code>. URLs serão convertidas para links automaticamente.)