Page 1 of 1

Distribute PHP EchoS towards separate fields - How ?

Posted: Thu Feb 08, 2018 8:44 pm
by teriibi
Hi,
Is there a way to distribute the returned values of 2 Echos into 2 dif. LC fields ?
i.e.

Code: Select all

<?php
echo "Start date : ".$date1;
echo "End date : ".$date2;
?>
Both values will "fall" into a single LC field, or is it just the only way PHP Echo does works :?:
:roll:

Re: Distribute PHP EchoS towards separate fields - How ?

Posted: Thu Feb 08, 2018 11:48 pm
by ghettocottage
your could simplify your php to just this

Code: Select all

<?php    echo  $date1.",".$date2;  ?>
and then in your LC App do something like:


Code: Select all

put it into toParse
   repeat with i = 1 to the number of lines of toParse
      put item 1 of toParse into field "start date"
      put item 2 of toParse into field "end date"
 end repeat

Re: Distribute PHP EchoS towards separate fields - How ?

Posted: Fri Feb 09, 2018 2:45 am
by teriibi
ok, so gathering both echos - into one line - first, is a must ? ...
PS: Works perfectly, Tks again !!

On the other side if there is another way to dispatch them properly even when they are on two distinct lines ..i m still intereted :wink:
(thats the case for now)

Re: Distribute PHP EchoS towards separate fields - How ?

Posted: Fri Feb 09, 2018 5:19 am
by ghettocottage
You could do it either way. If you want it on separate lines you could do something like:

Code: Select all

<?php
echo $date1.",";
echo $date2;
?>
then with LC just do the same thing as my other reply. Adding the comma will give LC something to use as a delimiter. There is probably another way, as usual with coding, but this should work

Re: Distribute PHP EchoS towards separate fields - How ?

Posted: Fri Feb 09, 2018 12:39 pm
by AxWald
Hi,

that's easy. If I fill your variables with date("c") each, your .php returns:

Code: Select all

Start date : 2018-02-09T12:18:49+01:00End date : 2018-02-09T12:18:49+01:00
So the second string starts with "End date :". Here we go:

Code: Select all

on mouseUp
   --  get URL myPhp  --  we would fetch the php data this way
   get "Start date : 2018-02-09T12:18:49+01:00End date : 2018-02-09T12:18:49+01:00"
   --  but we already know the data ;-)

   put CR after char offset("End date :", it) -1 of it
   put line 1 of it into fld "Start"
   put line 2 of it into fld "End"
end mouseUp

Re: Distribute PHP EchoS towards separate fields - How ?

Posted: Fri Feb 09, 2018 7:39 pm
by teriibi
Thanks to both, I ll keep that at hand, very usefull !
:idea: