Re: Check if Record was Entered Today.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, May 24, 2007 12:42 pm, Rahul Sitaram Johari wrote:
>
> Ave,
>
> I have a dbase (dbf) database and I¹m using PHP¹s dbase function to
> open &
> search the database.
> Each row in the database contains an Account Number and the Date it
> was
> inserted.
>
> I want to search this database for to see if the Account number
> ($thekey)
> was inserted today (using date() to find out today¹s date).
>
> Essentially, here¹s the code:
>
>     $db = dbase_open(try.dbf", 0);
>     if ($db) {

$exists = false;
$today = false;

>       $record_numbers = dbase_numrecords($db);
>         for ($i = 1; $i <= $record_numbers; $i++) {
>         $row = dbase_get_record_with_names($db, $i);
>
>             $thedate = date(mdY);
>             if(($row['ACC'] == $thekey) && ($row['DATE'] == $thedate))
> {
//>             echo "The Account Number has already been entered once
//> today";
//>             echo $row['DATE']." : ".$thedate;
//>             exit;
$today = true;
>             }
>             else {
//>             echo "The Account Number exists but not entered
//> today<br>";
//>             echo $row['DATE']." : ".$thedate;
//>             exit;

$exists = true;

>             }
>         }
>     }

if ($today) echo "Yes, today.";
elseif ($exists) echo "Yes, but not today.";
else echo "No.";

> The problem is ­ the scripts stops at the first entry of the Account
> Number,
> and is not looping through all the rows which contain the Account
> Number. So
> if the Account Number was entered yesterday, it stops and gives ³The
> Account
> Number exists but not entered today² even though the Account Number
> does
> exist in another row with Today¹s Date.

exit; completely halts a script and does NOTHING else.

You  maybe thought you wanted 'continue' or 'break' but those wouldn't
work for this either.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux