hi,

i've got a really annoying problem with php.

i need to generate a report that is quite complex and have done 99% of the
work but am stuck on the final leg.

what i need to do is extract the last visit of training staff from an
appointments table. simple you might think.

the sql "selelect max(start_date) from appointments where cdb=2044 and
start_date < now()" works fine in pgsql. (cdbs are customers.)
but does not work in php.

start_date is stored in postgresql as a timestamp.

the current query on the page looks like this:

for ($x=0; $x<$numcdbs; $x++)
{
        $cdbarr = pg_fetch_array($cdbs,$x);

// get last visit from appointments table
//$now = gmmktime("Y-m-d");
$date = gmdate("Y-m-d h:m:s",time());

$lastv = pg_Exec($conn,"select max(start_date) from appointments where
cdb=".$cdbarr["cdb"]." and start_date < '".$date."'");

print "select max(start_date) from appointments where cdb=".$cdbarr["cdb"]."
and start_date < '".$date."'<br>";

$numlastv=pg_numrows($lastv);
if ($numlastv > 0)
{       
        $lastvdets = pg_fetch_array($lastv,0);
        $lastvisit = gmdate("d/m/y",strtotime($lastvdets["start_date"]));

        
}

}

the code is returning $lastvisit at 08-05-01 in all cells ...

????????????????????????????????????????????
Steve Brett 
Internal Development
tel: 4251 
EMIS Ltd. 
"Privileged and /or Confidential information may be contained in this
message. If you are not the original addressee indicated in this message (or
responsible for delivery of the message to such person), you may not copy or
deliver this message to anyone. In such case, please delete this message,
and notify us immediately. Opinions, conclusions and other information
expressed in this message are not given or endorsed by my firm or employer
unless otherwise indicated by an authorised representative independently of
this message."
Egton Medical Information Systems Limited. Registered in England. No
2117205. 
Registered Office: Park House Mews, 77 Back Lane, Off Broadway, Horsforth,
Leeds, LS18 4RF



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to