RE: [PHP] Check if Record was Entered Today.
| From: | Jim Moseby | Date: | Thu, 24 May 2007 17:54:54 +0000 |
| Subject: | RE: [PHP] Check if Record was Entered Today. | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-255548@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: Rahul Sitaram Johari [mailto:sleepwalker@rahulsjohari.com]
> Sent: Thursday, May 24, 2007 1:42 PM
> To: PHP
> Subject: [PHP] Check if Record was Entered Today.
>
>
>
> 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) {
> $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;
> }
> else {
> echo "The Account Number exists but not entered
> today<br>";
> echo $row['DATE']." : ".$thedate;
> exit;
> }
> }
> }
>
> 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.
>
> How do I make it loop through all the rows and check if there
> is any entry
> with the Account Number & Today¹s Date?
>
> Thanks,
'exit' terminates the script. You should not be using exit there.
JM