0

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());
    }
2
Contributors
3
Replies
38
Views
1 Year
Discussion Span
Last Post by masimies
0

Have you checked the content of $row array
Near line no 15:
Debug like this way, by adding the following code

$row = mysqli_fetch_array($result)
var_dump($row)

Edited by panduranga_1

0

Yes, there is content in selection-list. That var_dump get those dissapering.
After selection, startrow is not functioning. It doesn't keep the selected value, and show next rows.

0

After hard testig and basket of beer, i figure this out. Tested and working, with adding filter-value within startrow-variable in href-link:
<a href="'.$_SERVER['PHP_SELF'].'?icycle='.$icycle.'&startrow='.($startrow+10).'">

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.