This topic is locked
[SOLVED]

 Populate field with dates

7/27/2012 12:21:54 PM
PHPRunner General questions
W
wundebar author

Hi at all.

I have this code



if ($data["scadenza"]=="1")

{

$value = date('d/m/Y',strtotime("+1 day"));

}

if ($data["scadenza"]=="2")

{

$value = date('d/m/Y',strtotime("+2 day"));

}

if ($data["scadenza"]=="3")

{

$value = date('d/m/Y',strtotime("+3 day"));

}

if ($data["scadenza"]=="4")

{

$value = date('d/m/Y',strtotime("+4 day"));

}

if ($data["scadenza"]=="5")

{

$value = date('d/m/Y',strtotime("+5 day"));

}

if ($data["scadenza"]=="10")

{

$value = date('d/m/Y',strtotime("+10 day"));

}

if ($data["scadenza"]=="30")

{

$value = date('d/m/Y',strtotime("+1 month"));

}

if ($data["scadenza"]=="60")

{

$value = date('d/m/Y',strtotime("+2 month"));

}


I've put it on "View as" - "custom" in editor page and it works, it show me different dates on field "calcolo" where it is.

The problem is that data are not stored into mysql, in fact if i go to check on mysql i'm not able to see the new data.

I seen that in events page there is a simple code ( $strSQLInsert) who can help me to fill also the fields of mysql, but maybe i'm doing something wrong.

Someone can show me how i can do a calculation of dates ( like with my code above) and save it into mysql?

Thanks in advance for help.<img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=19895&image=1&table=forumtopics' class='bbc_emoticon' alt=':)' />

P
procheck 7/28/2012

Hi,
Are you doing this on the List Page? The View As will not save it there. To update the table, you need to to use the edit page. If you want it saved from the List page, you'll need to write an Update SQL. I can help you with this if required.
Al
P.S. - The View As custom variables are also not sortable.

W
wundebar author 7/30/2012



Hi,
Are you doing this on the List Page? The View As will not save it there. To update the table, you need to to use the edit page. If you want it saved from the List page, you'll need to write an Update SQL. I can help you with this if required.
Al
P.S. - The View As custom variables are also not sortable.


Hi prochecksports, thanks for reply!

Yes i'm doing it into list page, and yes my new data are not saved.. it's like a temporary "image" of the calculation. <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=67199&image=1&table=forumreplies' class='bbc_emoticon' alt=':(' />

So if i understand correctly, i have to put my code into "edit page" (custom view) instead of "list page"? I'm sorry, as you can see i'm not so expert! <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=67199&image=2&table=forumreplies' class='bbc_emoticon' alt=':)' />

Thank you.

P
procheck 7/31/2012

You might not be an expert today, but one day you might be.
The best place is usually on the edit page in BeforeEdit (see the manual for how this works).
The "View As" custom displays the data with a variable which I assume is how you're doing it.

If you must use the list page with a custom variable and you want an update, then you will need

to code your own update SQL. This can be done in BeforeProcessRowList.
W3Schools - PHP MySQL Update
Example:
$updaterec = "UPDATE TABLE SET Field='".$variablename."'

WHERE ....; "

$sqlquery = CustomQuery($updaterec);

if (!$sqlquery)

{

$message = "Error when updating the Standings: Error ####";

return false;

}
Al