Jump to content

While Statement


user4fun

Recommended Posts

I am trying to make certain actions take place for the first 3 rows found and then other actions for the other rows from 4 to 6. This is what I have so far. I am not being able to test it at this time. Can anyone see why it might not work?.

Function WeHave($result){global $num_rows;global $result;$num_rows = mysql_num_rows($result);$i = 1;while($foundrow = mysql_fetch_array($result))	   {	 echo $i " - ";	 echo $foundrow['FirstName'] . " " . $foundrow['USERID'];	 echo "<br />"; 	 $i++;	 if ($1==4)			  {				   echo $num_rows . " RESULTS were found but we have to do something else starting at row 4"; 				  					for ($i=4; $i<=6; $i++)					   {				 echo $foundrow['FirstName’] . " " . $foundrow['LastName'];				   echo "<br />"; 						}			  }  	   }echo " If you reached this. It means that ONLY 3 or less results were found.";echo " We had " $num_rows;}

Link to comment
Share on other sites

I would not be using the While clause there. Ypu would be better off using a single for-loop and handling the first three in one manner, the next three in a second manner.Also, do you have a LIMIT clause on the Mysql query? Since you are dealing with only the first 6 rows, just place a limit on the number of returned rows in the Query.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...