0

I have a query

$result = $conn->query("select * from cabs where po = '$po' and Anew > $filter ORDER BY title limit $cnt,1")

that works fine and populates a file base on the $cnt that is populated based on click the next or previous button to go to a record. was does not work is the $filter, no matter what filter is set to it returns all records. any way to fix this.

var po =  $('#po').val();
            $.ajax ({
                type: "POST",
                url: "poInfo2.php",
                //async:false,
                dataType: "json",
                data: ({po:po , filter:$('#filter').val(), cnt:cnt, end:$('#end').html() }),
                success: function(data){
                    $("#end").html(data.pages);
                    $("#start").html(cnt+1);
                    var isbn = data.isbn;
                    
                     $("#cnt").val(data.cnt);
                     
                     pages of code that fills in a table
                     
                     
                     
                     
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script>

so what i want to do is remove the records from the start (so instead of showing the total at 16 if their were 4 records with filter below anew then it would show 12 and be able to scroll through - cannot move data from the table because it is editable by the front end users.

ForgivenIT
  • 169
  • 13
  • what do you get for `$('#filter').val()`? or `$_POST['filter']` in php? – Jeff Aug 25 '17 at 01:36
  • $filter = $_POST['filter']; filter is either 1,2,3 depending on selection then i have if($filter==1 || $filter==0 ||$filter==" " ||$filter == null || $filter==4) { $filter=-1000000000000000; } else if($filter==2 ) { $filter=2; } else if($filter==3 ) { $filter=-5; } – ForgivenIT Aug 25 '17 at 11:56

1 Answers1

0

You need you use quotes for the filter variables.

select * from cabs where po ="$po" and test  >  "$t" ORDER BY title limit $cnt,1

Second thing here is your variable inside single quotes can't be executed as dynamic it's just a text for php.

You must use it like "select * from abc where name = '".$name."'

  • That does not make any changes to the output, the question is how to change the $cnt if Anew > '".$filter."' – ForgivenIT Aug 25 '17 at 12:03
  • Sorry I didn't got you here. Can you be more precise about this. – Muhammad Zubair Saleem Aug 25 '17 at 12:24
  • I have a screen where a user enters the values they want to filter either all or -2, or 2 (the anew needs to be above the filter..easy no problem) but the trick is that it displays one row of the table at a time in a grid so they can see everything. it goes to the next row when they click a button, that row is called by running the query again with cnt+1 or cnt-1 depending on which row they want...So if i take the $cnt out no problem but with the $cnt in it pulls all results no matter what the $filter is set to – ForgivenIT Aug 25 '17 at 12:48
  • @ForgivenIT for that why don't you use the last row unique id as filter as i used that thing once which gives me the greater then or less then like thing. Lets say you have checked a value having row id 1 and wants to move next having row id 2 so you can put that thing there like if filter is greater then 1 then it will show just 2 row and so on. Hope you got my point. – Muhammad Zubair Saleem Aug 25 '17 at 19:02