Jump to content
migaz

pagination array php

Recommended Posts

migaz

Eu estou a fazer um web aplication para uma empresa , e tenho que fazer algo como uma pagina de reports que tem como exemplo data e hora em que foi detetado um erro na maquina , que utilizador estava logado nesse momento, ... Deveria de ter 2 butoes(anterior/seguinte), que permite-se que o utilizador pude-se ver esse dados para os utilizadores filtrados na pagina anterior(codigo dos utilizadores ) , 1 a 1 e em ordem de filtragem. O que acho que me falta fazer e chamar na pagination o array dos utilizadores e algo mais que não sei bem o que poderá ser .Será que me poderiam dar uma ajuda?

codigo pagination

<?php


include('../bd_connection.php');
session_start();//start session for this page
$id = "";
if(isset($_POST['select4'])){ $id = $_POST['select4'];}

$linecount2 = "";
if(isset($_POST['select3'])){ $linecount2 = $_POST['select3'];}
$value2 = "";
if(isset($_POST['select5'])){ $value2 = $_POST['select5'];}
$query = "EXEC AuditDetails @registryID='$id'";
$result = odbc_exec($conn,$query);
$_SESSION['show'] = $value2; //register it with session
if(isset($_SESSION['show'])){

//instantiate variables
$currentpage = isset($_GET['pagenum']) ? (integer)$_GET['pagenum'] : 0;
$offset = ($currentpage - 1) * $limit;





$numperpage = $linecount2; //number of records per page
$numofpages = count($_SESSION['show'])/$numperpage; //total num of pages
$first = 0; //first page
$last = $numofpages;

if($currentpage==0){ //which page is previous
	$previous = 0; //if very first page then previous is same page
}else{
	$previous = $currentpage-1;
}

if($currentpage==$last-1){//which page is last
	$next = $currentpage;
}else{
	$next = $currentpage+1;
}

for($x=($currentpage*10);$x<(($currentpage*10)+10);$x++){ //output data
	echo ($x+1)." ".$_SESSION['show'][$x]."<br>";
}
echo "<a href='process_detais_operation.php?pagenum=".$previous."'>Previous</a>						<a href='process_detais_operation.php?pagenum=".$next."'>Next</a>"; //hyperlinks controls
}



echo "

<div id='contador' style='margin-left:0m;width:25.6em;text-decoration:none;float:left;'>
<label for='contador' style='margin-left:0em'>Contador</label>
<br>
<input type='text' id='contador style='width:100%;margin-left:0em;background-color:#E8E8E8;' value='$value2[registryID]/$linecount2' />
</div>
";

echo "
<div id='data' style='margin-left:0em;width:25.6em;text-decoration:none;float:left;clear:both;''>
<label for='date' style='margin-left:0em;'>Data</label>
<br>
<input type='text' id='data' style='width:100%;background-color:#E8E8E8;'value='$value2[timestamp]' />
</div>";

echo "
<div id='utilizador' style='margin-left:3em;width:25.6em;text-decoration:none;float:left;''>
<label for='utilizador' style='margin-left:0em;'>Utilizador</label>
<br>
<input type='text' id='utilizador' style='width:100%;background-color:#E8E8E8;' value='$value2[userName]' />
</div>
";

echo "<div id='funcao' style='margin-left:3em;width:25.6em;text-decoration:none;float:left;'>
<label for='funcao' style='margin-left:0em;'>Função</label>
<br>
<input type='text' id='funcao' style='width:100%;background-color:#E8E8E8;' value='$value[functionName]' />
</div>";

echo "<div id='tpregisto' style='margin-left:0em;width:25.6em;text-decoration:none;float:left;clear:both;''>
<label for='tpregisto' style='margin-left:0em;''>Tipo de Registo</label>
<br>
<input type='text' id='tpregisto' style='width:100%;background-color:#E8E8E8;' value='$value[registerTypeDescription]' />
</div>";

echo "<div id='origem' style='margin-left:3em;width:25.6em;text-decoration:none;float:left;''>
<label for='origem' style='margin-left:0em;'>Origem</label>
<br>
<input type='text' id='origem' style='width:100%;background-color:#E8E8E8;' value='$value[registerOriginDescription]' />
</div>";

echo "<div id='valor' style='margin-left:3em;width:25.6em;text-decoration:none;float:left;'>
<label for='valor' style='margin-left:0em;'>Valor</label>
<br>
<input type='text' id='valor' style='width:100%;background-color:#E8E8E8;'value='$value[value]' />
</div>";

echo "<div id='ra' style='margin-left:0em;width:25.6em;text-decoration:none;float:left;clear:both;'>
<label for='ra' style='margin-left:0em;'>Referência ALIAS</label>
<br>
<input type='text' id='ra' style='width:100%;background-color:#E8E8E8;'value='$value[manufacturerReferenceAlias]' />
</div>";

echo "<div id='sq' style='margin-left:3em;width:25.6em;text-decoration:none;float:left;'>
<label for='sq' style='margin-left:0em;'>SpareBox quantity</label>
<br>
<input type='text' id='sq' style='width:100%;background-color:#E8E8E8;'value='$value[sBquantity]' />
</div>";

echo "<div id='ce' style='margin-left:3em;width:25.6em;text-decoration:none;float:left;'>
<label for='ce' style='margin-left:0em;'>Código Erro</label>
<br>
<input type='text' id='ce' style='width:100%;background-color:#E8E8E8;'value='$value[errorCode]' />
</div>";

echo "<div id='descricao' style='margin-left:0em;width:83em;height:11em;text-decoration:none;float:left;clear:both;'>
<label for='descricao' style='margin-left:0em;'>Descrição</label>
<br>
<input type='text' id='descricao' style='width:100%;height:100%;background-color:#E8E8E8;' value='$value[description]' />
</div>";

echo "<div id='ed' style='margin-left:0em;margin-top:2em;width:83em;height:10em;text-decoration:none;float:left;clear:both;'>
<label for='ed' style='margin-left:0em;'>erroDescription</label>
<br>
<input type='text' id='ed' style='width:100%;height:100%;background-color:#E8E8E8;'value='$value[errorDescription]' />
</div>";

 ?>

codigo dos utilizadores

$query = "EXEC AuditSearch @dateStart='$idatestart',@dateEnd='$idateend',@userID='$iuser',@registryTypeID='$itype',@registryOriginID='$iorigin',@recordsNumber = '10'";
$result = odbc_exec($conn,$query);
$linecount =0;
if ($result !=0) {
echo '<table id="t01" class="t1" style="margin-left:1em; border-collapse: collapse;">';//Create table
echo'<tr>
 <th>Data e hora</th>
 <th>Utilizador</th>
 <th>Tipo de Registo</th>
 <th>Origem</th>
 </tr>';



while ($show = odbc_fetch_array($result)) {
$ri = $show["registryID"];
$location = $show["timestamp"];
$references = $show["userName"];
$capacity = $show["registerTypeDescription"];
$quantity = $show["registerOriginDescription"];
$linecount++;



echo"<tr>
<td style='display:none;'>$ri</td>
<td >$location</td>
<td >$references</td>
<td >$capacity</td>
<td >$quantity</td>
	 </tr>";
 }

echo '</table>';

}

Edited by migaz

Share this post


Link to post
Share on other sites
HappyHippyHippo

antes de tudo necessitas de guardar os parâmetros da filtragem (por ventura, em sessão)

depois, já na página que pretendes apresentar os dados, terás de fazer a pesquisa recorrendo aos parâmetros da pesquisa anterior e limitar ao índice do registo que pretendes


IRC : sim, é algo que ainda existe >> #p@p

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. 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.