cervinakuy
Joined: 23 Aug 2005
Posts: 5
Posted: 2005-08-23 18:45
Back to top
Reply with quote
|
I am a newbie so please try to be as detail as possible. I am incorporating easyphpcalendar to my database. The problem is the date column uses julian day numbers and I would like to have a human readable column for this table.
I was able to display the correct date using the php function jdtogregorian (number); however, it does not work inside phpmyedit.
The date field in the easyphpcalendar script is int(11).
i.e:
<?php
$month1=10;
$day1=11;
$year1=2005;
$julian_number=gregoriantojd($month1,$day1,$year1);
echo "Julian Day Number=$julian_number";
?>
The result is: 2453655 and matches the value in the database.
Now going the other way:
<?php
$gregorian_date=jdtogregorian($gregorian_1);
echo "Gregorian Date=$gregorian_date";
?>
Where gregorian_1 is the value above gives me the correct date.
How can I execute this same function within phpmyedit? Any ideas?
Thanks for your assistance,
-L
|
ajh
Joined: 17 Dec 2003
Posts: 236
Posted: 2005-08-24 07:41
Back to top
Reply with quote
|
Have a look at the section on triggers, that will allow you to use PHP functions.
A simpler way might be to use the 'sql' and 'sqlw' options and do the conversion in MySQL, however MySQL does not have an in-built convertor function. Assuming that your dates are recent (ie. since the creation of the gregorian calendar), could you just pick a fixed date (say 1st Jan 1900), calculate the JD number for that date, subtract that from the value in the column and that would give you the days since 1st Jan 1900. You could then use the MySQL ADDDATE function to create the correct date. You would then do the reverse in the 'sqlw' expression to convert it back.
|
cervinakuy
Joined: 23 Aug 2005
Posts: 5
Posted: 2005-08-24 18:52
Back to top
Reply with quote
|
Thanks for the help. I was stuck and run out of ideas. I will try using the adddate function and using sql and sqlw. :)
|
cervinakuy
Joined: 23 Aug 2005
Posts: 5
Posted: 2005-08-26 21:08
Back to top
Reply with quote
|
Ajh,
Following your suggestion, this what I put together:
$opts['fdd']['startDate'] = array(
'name' => 'StartDate',
'select' => 'N',
'maxlen' => 11,
'default' => '0',
'required' => true,
'sql' => 'adddate(19000101, interval $val-2415021 day)',
'sort' => true
);
However, it gives me the following error message:
MySQL error 1054
Unknown column '$val' in 'field list'
In page 31 of the documentation, it states:
$val -- value of the field
What could be wrong?
Thank You!
|
ajh
Joined: 17 Dec 2003
Posts: 236
Posted: 2005-08-30 09:06
Back to top
Reply with quote
|
In 'sql' you should use the actual column name. $val is for use in 'sqlw' (ie writing back to the database).
'sql' reads from the database
'sqlw' writes to the database
|
cervinakuy
Joined: 23 Aug 2005
Posts: 5
Posted: 2005-08-30 21:22
Back to top
Reply with quote
|
Okay. Following your instructions, I came up with this:
$opts['fdd']['startDate'] = array(
'name' => 'StartDate',
'select' => 'N',
'maxlen' => 11,
'required' => true,
'sql' => 'adddate(19000101, interval startDate-2415021 day)',
'sqlw' => 'datediff($val, 19000101)+2415021',
'sort' => true
It displays the date correctly, and also adds a record correctly. Thank You!!!
However, if I try to change/copy an existing record value then the value of the startdate field gets erased. Does the 'sqlw' option work when modifying a record?
Thanks for all your help!
--Luis
|
Jochen
Joined: 22 Oct 2004
Posts: 7
Posted: 2005-09-01 22:11
Back to top
Reply with quote
|
cervinakuy wrote: |
However, if I try to change/copy an existing record value then the value of the startdate field gets erased. Does the 'sqlw' option work when modifying a record? |
AFAIK sqlw works with 'change' too. What do you mean with 'erased'? Empty? What's the field type in mySQL?
Did you update the core script from 5.4 to the CVS version? If not - try that - fixed many bugs for me.
|
cervinakuy
Joined: 23 Aug 2005
Posts: 5
Posted: 2005-09-04 21:47
Back to top
Reply with quote
|
AFAIK sqlw works with 'change' too. What do you mean with 'erased'? Empty? What's the field type in mySQL?
'erased' means the field becomes a null value. I have it defined as intenger 11 in mySQL.
Did you update the core script from 5.4 to the CVS version? If not - try that - fixed many bugs for me.
Not sure. I will check the core script version to make sure it is the CVS version. As a work around using the cal extension, this problem dissapears.
I will check the version number, but I will just use the cal extension for now.
Thanks for the help!
|
ajh
Joined: 17 Dec 2003
Posts: 236
Posted: 2005-09-05 11:56
Back to top
Reply with quote
|
I strongly recommend that you use the latest CVS version - plus if you are using the cal extension, make sure you use mce_cal, and not calpopup (which doesn't work with the CVS version).
|
RaymMays
Joined: 27 Oct 2020
Posts: 1
Posted: 2020-10-27 09:45
Back to top
Reply with quote
|
In our topic PHP, my edit configuration (datemarks on date field )is based on the debugging problem I have faced. Afterwards, we read this topic I can easily be debugging my program
NerdyWriters
I also use it please give me your feedback.
|
followersaustrali
Joined: 03 Dec 2020
Posts: 4
Posted: 2020-12-05 11:03
Back to top
Reply with quote
|
I am trying to update posting.php and cannot find this text: # ... Here is my posting.php file: ... If the mode is set to topic review then output
buy followers australia
|
dustinhunt
Joined: 01 Mar 2021
Posts: 4
Posted: 2021-04-20 07:43
Back to top
Reply with quote
|
You can alter your PHP configuration using a.htaccess file when your server runs PHP as an "Apache module." A.htaccess folder is a type of config file that can be used to modify a variety of settings panel, like PHP configurations. Source:
professional essay writers UK
of UK Writing Experts.
|
Post new topic
Reply to topic
|