This topic is locked

Get data from..yesterday?

2/3/2010 9:27:29 AM
PHPRunner General questions
S
sickacid author

Hi, i've a table where i put every day the start and the end of Kilometers of any veicle.

for example
DAY----Vecile----KmStart----Km End

04------1----------10-----------20

04------2---------200----------300

05------1----------20-----------30

05------2---------300----------451

06------2---------451----------467

ecc...
The end of day 04 for veicle 1 is 20 Km like the start of day 05 for veicle 1
I want to report this '20' automaticaly in the add page

I've do this in add page: before display

i want to put the '20' in the field KmInizio automaticaly.

But it don't works... off course, The search should seek at the maximum

value, and not in the yesterday value in that vehicle. <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=13698&image=1&table=forumtopics' class='bbc_emoticon' alt=':unsure:' />
global $conn;

$id = $values["IdTarga"];

$str = "select KmFine from tabelladischetti where Id='".$id."'";

$rs = db_query($str,$conn);

$data = db_fetch_array($rs);

$KmFine = $data["KmFine"];

$xt"KmInizio";

J
Jane 2/4/2010

Hi,
you can select max value from database usign this query:

$str = "select max(KmFine) from tabelladischetti where Id='".$id."'";
S
sickacid author 2/4/2010

Hi Jane, i've do this code in add page: before display
global $conn;

$id = $values["IdTarga"];

$str = "select max(KmFine) from tabelladischetti where Id='".$id."'";

$rs = db_query($str,$conn);

$data = db_fetch_array($rs);

$KmFine = $data["KmFine"];

$xt["KmInizio"]=($KmFine);
but'i've got an error type 8, Undefined variable: values

Sergey Kornilov admin 2/4/2010

BeforeDisplay event doesn't access to $values array. Since this is the Add page no values exist yet.