PHP version - Do while not EOF (ASP)

Soldato
Joined
20 Oct 2002
Posts
6,212
Location
UK
i'm having afew problems converting this into PHP:
Code:
--- ASP Version ---
If (Not rsClean.EOF) Then
	Do While Not rsClean.EOF
		////////// Do Stuff
	Loop
End If
rsClean.EOF is a recordset from a stored proceedure pulling *currently* 154 records from a database... the /////// Do Stuff section makes a date comparison and if a file exists that is over 3 days old with a reference number from rsClean it is deleted...

all of this is fine, other than the flipping loop, whats the PHP equivilant of:

DO While Not .EOF?
 
using a function i now know exactly how many rows are being returned by the stored proceedure each time the page is run,

is there any way of returning a specific row? like the 72nd row which met the criteria of:

Select * from TableName where (Z = Z) AND (V = V)

?
 
Last edited:
Are you looping through a file, or are you looping through a database resultset? If it's the latter, what database are you using?

In PHP there are database vendor-specific functions like mysql_fetch_assoc() for MySQL and pg_fetch_assoc() for Postgres, or you can use a data-access abstraction layer like PDO. The examples in the docs contain looping structures for iterating through a resultset.

If it's a file then check out the examples for fgets()

And for basic docs on control structures like while / do while loops: http://uk2.php.net/manual/en/language.control-structures.php
 
hi, im using ODBC

i'll take another look at your links when im back in at work infront of the code on monday :)

thanks for the reply
 
ended up with this and it seems to work :)

Code:
$rsClean = odbc_exec(connection,"exec stored procedure @f_ref_link='%'");
while (odbc_fetch_row($rsClean)) {

}

Cheers :D
 
Back
Top Bottom