Hello,
I try to limit query results and fetched items in same time.
But, with my script, that is not functioning together. Selected item is not staying as variable in query. Something is badly ordered in this script.
<?php
if (!isset($_GET['startrow']) or !is_numeric($_GET['startrow'])) {
$startrow = 0;
}
else {
$startrow = (int)$_GET['startrow'];
}
echo '<table class="tabs">
<td><a href="'.$_SERVER['PHP_SELF'].'?startrow='.($startrow+10).'"><input type="button" name="next" value="Next" class="nextbutton" /></a></td>
<form name="deal" method="post" action="">
<td><select required name="deal" onchange="javascript: submit()" class="tblselect">
<option value="">Period</option>';
$query = mysqli_query($db,"SELECT DISTINCT icycle FROM offer WHERE orderstatus='Billable' ORDER BY icycle ASC");
$result = ($query) or die ('Error in query: $query. ' . mysqli_error());
while($row = mysqli_fetch_array($result))
{
echo'<option value ='.$row['icycle'].'>'.$row['icycle'].'</option>';
}
echo'</select></td>';
$prev = $startrow - 10;
if ($prev >= 0)
echo '<td><a href="'.$_SERVER['PHP_SELF'].'?startrow='.$prev.'"><input type="button" name="prev" value="Previous" class="prevbutton" /></a></td></form></table>';
$fetch = mysqli_query($db,"SELECT * FROM offer WHERE icycle='Now' AND orderstatus='Billable' GROUP BY offerid ORDER BY custname LIMIT $startrow, 10")or die(mysql_error());
if(isset($_POST['deal']))
{
$deal = $_POST['deal'];
$fetch = mysqli_query($db,"SELECT * FROM offer WHERE icycle='$deal' AND orderstatus='Billable' GROUP BY offerid ORDER BY custname LIMIT $startrow, 10")or die(mysql_error());
}