| Index
» Projects
» phpMyEdit
» Forum
» fetch interval data from other table |
 |
Barbapapa
Joined: 21 Jul 2009
Posts: 2
Posted: 2009-07-21 23:21
Back to top
Reply with quote
|
Hello there :)
I am a new phpmyedit user and i try to learn php-mysql.
Until a few days ago, phpmyedit worked fine, but now i need a number (dagen) from an other table in the same database to do a DATE_ADD.
As you can see, in the code below, i am struggling with php, mysql and phpmyedit :)
I have been trying for days, what am i doing wrong?
| Code: |
$opts['fdd']['dagen'] = array(
'table' => 'adres',
'column' => 'dagen',
'sql|L' => 'SELECT dagen FROM `adres` WHERE 1 LIMIT 0, 30'
);
$opts['fdd']['Datum_ver'] = array(
'name' => 'Datum verlopen',
'select' => 'T',
'options' => 'FL',
'sort' => true,
'sql|LF' => 'if((CURDATE() < DATE_ADD(Datum, interval dagen DAY)) OR (CURDATE() < DATE_ADD(HDatum, interval dagen DAY)), Datum_ver, "Verlopen")'
); |
MySQL error:
| Code: |
MySQL error 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT dagen FROM `adres` WHERE 1 LIMIT 0, 30 AS qf5 FROM factuur AS PMEtable0 L' at line 1
phpMyEdit error: invalid SQL query
SELECT PMEtable0.id AS qf0,CONCAT(PMEjoin1.Naam,", ",PMEjoin1.tav) AS qf1,PMEtable0.Naam AS qf1_idx,PMEtable0.Datum AS qf2,PMEtable0.HDatum AS qf3,PMEtable0.VDatum AS qf4,SELECT dagen FROM `adres` WHERE 1 LIMIT 0, 30 AS qf5 FROM factuur AS PMEtable0 LEFT OUTER JOIN simpelfactuunl_testdb.klant AS PMEjoin1 ON (PMEjoin1.Naam = PMEtable0.Naam) ORDER BY PMEtable0.id DESC LIMIT 0,20 |
Thanks
|
doug
Joined: 10 Feb 2003
Posts: 1013
Location: Denver, Colorado (USA)
Posted: 2009-07-22 16:11
Back to top
Reply with quote
|
See the application of virtual (dummy) fields, and the "next to last" entry at the following link.
http://opensource.platon.sk/forum/projects/viewtopic.php?t=961&highlight=virtual+date+add
|
Barbapapa
Joined: 21 Jul 2009
Posts: 2
Posted: 2009-07-22 22:56
Back to top
Reply with quote
|
Thanks doug,
I have seen this thread before, but the virtual field did not work.
This is what i tried:
| Code: |
$opts['fdd']['vir_field'] = array(
'name' => 'virtual field',
'options' => 'L',
'select' => 'T',
'nowrap' => true,
'sort' => true,
'values' => array(
'table' => 'adres',
'column' => 'dagen',
'description'=> array(
'columns' => array('dagen, aid'),
'divs' => array(', '),
'orderby' => "dagen"
))); |
This is the error:
| Code: |
MySQL error 1054
Unknown column 'PMEtable0.vir_field' in 'on clause' |
I double checked table and column names. aid is the ID
Greetings.
|
|
Post new topic
Reply to topic
|
|
|
|