I guess one of the problems is that PHP has a limited number of dbase functions and I'm not able to run SQL Queries on a dbf database. Basically I have to make-do with the few dbase() functions I have available in PHP. But I do get your logic and it's pretty helpful. I did re-write the code using Boolean (flags) as Richard had also suggested and it works fine now! Still wish I could run SQL Queries or do more to a dbase database using PHP. Thanks! On 5/24/07 4:07 PM, "Jared Farrish" <farrishj@xxxxxxxxx> wrote: >> I believe you need a "while" instead of an "if". The "if" will only run >> until the first occurance is true. Whereas a "while" will run to find > all >> results that are true until it goes thru all of the result rows.. > > No, I think he's checking to make sure that $db contains a resource id and > not a boolean false (meaning the file did not load or contains no data). > > Maybe a more descriptive way may be to say: > > <code> > if ($db !== false && is_resource($db)) { > doStuff(); > } > </code> > > To the next problem: > >> 'exit' terminates the script. You should not be using exit there. > > When you want a loop structure to stop and goto what flows next in the code, > use break: > > <code> > for ($i = 0; $i < count($items); $i++) { > if ($items[$i] == $arbitraryCondition) { > echo 'I do not need to doStuff() anymore.'; > break; > } > doStuff(); > } > </code> > > When you want a loop structure to skip over something but still continue to > loop, use continue: > > <code> > for ($i = 0; $i < count($items); $i++) { > if ($items[$i] == $arbitraryCondition) { > echo 'I do not need to doStuff() on this item.'; > continue; > } > doStuff(); > } > </code> > > When reading through values in an array or other structure, you can while or > do/while loop: > > <code> > $db = getDb('location/db.dbf'); > while($row = db_fetch_array($result)) { > if ($row['AcctActivation'] != $date) { > continue; > } elseif ($row['AcctActivation'] == $date) { > break; > } > doStuff(); > } > </code> > > Isn't there a way to search for and select only the rows with the account > number though? If you're looking for needles in a (potentially large) > haystack, this sounds like an expensive process for something SQL or other > could do better/faster. > > ======== > > Incidentally, does this mean you solved the file access problems from this > thread: > > http://news.php.net/php.general/255542 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php