...

View Full Version : Assistance with Previous and Next Record



mwm
06-14-2006, 07:30 PM
I have a form that query's a mysql database and populates a table with the query results. Each result has a link pointing to an invoice in the db. I can display the img just fine. The problem is that when i try to display the previous or next record it finds the next idnum in the squence. In other words, if the idnum is 102 the next record would be 103. but that is not correct. I need the previous and next records that are the result of the query. As and eample query pulls records of 102, 120, 121, 128, I need to see when next is clicked from 102, 120, then next again see 128 so fourth. Below is the code I have. Any Help will be greatly appreciated.


<html>

<form name = "result" form action = "final.php" method ="POST">

<?
include ("conn1.php");

session_start();


$result = $_POST['result'];
$idnum = $_POST['idnum'];
$ven= $_POST['ven'];
$imageid = $_POST['imageid'];

$sql = "
SELECT idnum, ven,veninvoice,kirkcheck,community,imageid
FROM corp
WHERE ven LIKE '%$ven%'
AND veninvoice LIKE '%$veninvoice%'
AND kirkcheck LIKE '%$kirkcheck%'
AND community LIKE '%$community%'
AND idnum LIKE '%$idnum%'
AND imageid LIKE '%$imageid%' order by 'idnum'
";


$result= mysql_query($sql) or die ("Can't connect");
$invoicetotal = mysql_num_rows($result);

echo "Total Invoices $invoicetotal";

?>

<table border="0">

<th>Vendor</th>
<th>Invoice</th>
<th>Check</th>
<th>Community</th>
<?php

$j = 0;

$idnum = array();

while ($row = mysql_fetch_array($result)) {


echo ($j++%2==0) ? '<tr bgcolor="#FFFFCC">' : '<tr bgcolor="#FFFFFF">';
echo "<td>" .($row['ven']) . "</td>";
echo "<td>" .($row['veninvoice']) . "</td>";
echo "<td>" .($row['kirkcheck']) . "</td>";
echo "<td>" .($row['community']) . "</td>";

print '
<td>


<a href="final.php?idnum='.$row['idnum'].'">link</a>
</td>
';

}
echo '</table>';

?>
</form>
</html>




*******************next page***************

<html>
<style type="text/css">
body { color: black; background: #ffffaa; }
</style>
<form name = "final" form action = "final.php" method ="POST">

<?






include ("conn1.php");
session_start();
echo $result;




if(is_array($_POST["idnum"])) {


$idnum = implode(",",$_POST["idnum"]);
}


$query = "SELECT * FROM corp WHERE idnum='$idnum'";
$result1 = mysql_query($query);
$row = mysql_fetch_row($result1);
$imageid = $row[5];

echo "<img src=$imageid.gif border = 4 align = right width=\"88%\">";




$previd = $idnum -1;
$nextid = $idnum +1;

echo "<a href =\"final.php?idnum=$nextid\">Next</a><BR>";
echo "<a href=\"final.php?idnum=$previd\">Previous</a><BR>";
echo "<a href =\"corpfind.php\">New Search</a><BR>";




?>


</body>
</html>

mwm
06-14-2006, 08:41 PM
Any Thoughts?

Thanks



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum