0
I have a variable $x = 0
and the $y = 10
in the following query:
select * from tabela limit 10 offset 0
This query makes a loop, more it would need in that loop the value of the offset
increase +10
every loop until it reaches the last query line to stop the loop, someone knows how I can be doing this:
My code is like this:
$conexão = mysql_connect('localhost','root','password');
$db = mysql_select_db}('banco');
//essa query é pra fazer o loop da segunda query
$sql = "select * from tabela";
$query = mysql_query($sql);
$rows = mysql_num_rows($query);
while($rows > 0){
//define o limit
$x = 0;
//define o offset
$y = 4;
//essa query é que vai retornar a informação
$sql = "select * from limit $y offset $x";
$query = mysql_query($sql);
while($row = mysql_fetch_array($query){
resultado da segunda query;
}
}
I would need to do this because I have a table of 5 thousand lines, I need to get all the lines only parceled 100 in 100 lines, the loop only takes from the first line up to the limit that is 10 in the example, what I’m trying to do in this loop:
I don’t know if I got the problem right, but it’s not just adding up how much you want to offset the $y variable at the end of the first while?
– Renato Tavares
The suggestion is to clarify all the details in the previous question. Feel free to ask separate questions about separate problems, but try to solve each issue.
– Bacco
@Bacchus believed none, but in the previous problem he had failed to explain the problem very well and no one had answered accordingly. I believe I already answered it in the original question in an acceptable way. And I think the question here can be marked as duplicate.
– tayllan
@tayllan I reread the two, then ended up closing when I edited the previous comment. If your answer didn’t solve his problem, it would be his case to edit that one and explain the question better. Both "versions" are so confusing. Actually I’m thinking that the previous one is already duplicate, but I’ll wait for Danilo to clarify that one so we can see how to help better.
– Bacco