1
Does anyone know if in that PHP function - mysql_num_rows
has to do with me making a while
in it? I need to break the total number of rows in the table. I tried to do:
$sql = "select ...";
$query = mysql_qery($sql);
$rows = mysql_num_rows($query);
while(!empty($rows)){
}
I tried the !isset
, variable = ""
, variable = 0
but it makes an infinite loop and only takes the first crease query block lines, also tried to make a for
but it didn’t work either.
I’ve tested with echo
the screen return variable.
Keep making an infinite loop, I need this loop to take a range of lines I declared two variables, one for the
$inicio = 0;
and the other for the limit
$limit = 100;
range would be the block between start and limit and while loop incrementing the value of limit in offset, I tried to do:
$offset = $offset+$limit;
and
$offset = $offset+100;
the more he takes only the first lines and makes the infinite loop on that first line.
Does anyone have an idea how to fix this?
i wanted to change the $offset variable every time I loop the value would be the value of the $limit variable that will be fixed has to do this dynamically in php
By the function mysql_num_rows, you have already checked if you are returning the right count?
– Viniam
First, give an echo $Rows. If returned right value, change your while: while($Rows > 0){
– Diego
What you want is a
for
, probably and not awhile
. Now, it seems that it is the case to useLIMIT
SQL will use only part of the lines. If you want to group the rows from 10 to 10, for example, or by headers/footers to each N records, already have answers on the site about this. If you are going to use for paging, you also have.– Bacco
@daniloeugenio I believe I have finally understood your question from your other question (which is a duplicate and you should remove). In it you explained a little better about what you wanted. See if my answer below answers the question.
– tayllan
@Danilo, as I commented in your new question, you better [Dit] this one and explain the problem very clearly, instead of opening new questions about the same problem. Try to give as much detail of the result you want to get in the question itself, which makes it easier for the community to help.
– Bacco