Hey Guys,
I am making a counter to loop through the results as follows.
Since I already did a do while loop, I used the "mysql_data_seek($apartments,0)" to reset the pointer to the first point.
<?php
$emptycounter=0;
if($totalRows_apartments>0){
//Reset Counter of pointer.
mysql_data_seek($apartments,0);
do{
if(empty($row_apartments['apartment_no'])){
echo $row_apartments['contract_id2'] . "<br />";
$emptycounter++;
}
}while($row_apartments = mysql_fetch_assoc($apartments));
}
if ($emptycounter==0){
echo "No Empty Contracts Available";
}
?>
The problem with this is that the counter counts an additional row that does not exist meaning that it will always output an empty value at the beginning of the loop, and then output the correct values. When i set the mysql_data_seek to 1 instead of 0, the loop outputs an empty value at the beginning, and then the remaining correct outputs missing one of the required outputs.
How can the counter work if the conditional statement is false?
The query that i have only has 2 rows, how can the output/counter show 3. Even if i advance the mysql_data_seek to 1 instead of 0, the counter prints 2 and not 1.
if the Conditional statement in the empty is false, and not empty values were found, the counter returns as
1 which means that the statement was executed although it shouldn't have.
Thank you for your cooperation.
Sincerely,
Sherif