A: 

Use foreach to loop over an array rather than trying to access by indexes (if you're fetching every value):

foreach ($records as $record) {
}

instead of

for ($i = 0; $i < count($records); $i++) {
}

or

$i = 0;
while ($i < count($records)) {

    $i++;
}

or

$i = 0;
do {

} while (++$i < count($records));
ircmaxell
+1  A: 

SELECT * FROM products
WHERE razdel='mix' AND ID > $ID AND litraj='$litri' ORDER BY ID ASC";

Col. Shrapnel
A: 

Use this query instead:

SELECT * FROM products WHERE razdel='mix' AND ID>$ID AND litraj='$litri' ORDER BY ID ASC LIMIT 1

This will give you the next element after the one with ID of $ID.

moteutsch
I think this should do thank you. If I am having a problem I will write again.
Victor
OK But now I am getting a blank page because the query want's to show the next ID which is not matching the criteria I want to skip rows in which 'razdel' is not 'mix'
Victor
A: 

Change your query to this:

$query_Recordset10 = "SELECT * FROM products 
    WHERE razdel='mix' AND ID > '$ID' AND litraj='$litri' ORDER BY ID ASC LIMIT 1";

So you still only get 1 row returned (if there's anything to return), but you'll be returning the next row (according to ORDER BY ID ASC) versus (potentially) the row with an incremental ID.

mway
OK But now I am getting a blank page because the query want's to show the next ID which is not matching the criteria I want to skip rows in which 'razdel' is not 'mix'
Victor
+1  A: 

PROBLEM SOLVED. I still have a lot to learn.

SELECT * FROM products WHERE razdel='mix' AND ID>'$ID' AND litraj='$litri' ORDER BY ID ASC LIMIT 1

this is the wright line but my mistake was how $ID is generated.

Thank you all.

Victor