Just tried, isn't working! It's doing the same thing that exit; does.

Both

     else {
        echo "Not Found";
         break;
     }

And

     else {
        echo "Not Found";
         exit;
     }

Do the exact same thing. It will print "not found" (because it checks the
first row, and if the phone number is not in the first row), and basically
exit and not go further with the loop.


On 10/6/06 12:40 PM, "João Cândido de Souza Neto"
<[EMAIL PROTECTED]> wrote:

> Usen this:
> 
>     echo ³not found²;
>     break;
> 
> 
> ""Rahul S. Johari"" <[EMAIL PROTECTED]> escreveu na mensagem
> news:[EMAIL PROTECTED]
> Ave,
> 
> code:
> 
> $db = dbase_open("osm.dbf", 0);
> if ($db) {
>   $record_numbers = dbase_numrecords($db);
>   for ($i = 1; $i <= $record_numbers; $i++) {
>      $row = dbase_get_record_with_names($db, $i);
>      if ($row['PHONE'] == $thekey) {
>         echo ³found²;
>     }
>     else {
>     echo ³not found²;
>     break;
>     }
> }
> }
> 
> The loop reads each row in the database, and checks whether it matches
> $thekey or not. If it does, it prints ³found², if it doesn¹t, it prints ³not
> found². But this happens for ³each row² in the database. So if there are 100
> records, and the program does find a match, I¹ll get 99 ³not found² printed,
> and one ³found² printed.
> 
> I can easily put an ³exit;² after my echo in the else(), but then it stops
> the loop, and doesn¹t go any further.
> 
> What do I have to do to get results if the phone matches, print nothing for
> rows where it doesn¹t match, but give one single ³not found² if the phone
> number does not exist in the database?
> 
> The logic is just failing me at this point.
> 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to