My question is related to an answered question that was asked here on the ever reliable forum - Daniweb.
I have been trying to insert the parsed data as a string into mysql table in vain.
This is what i am trying to do.....
From the solution in the link above, i changed the code to this:
# loop each date > item > item
foreach($item as $elem)
$r= sprintf('%s %s %s'
, $elem->attributes()->Name
, $elem->attributes()->Type
, $elem);
}
I changed $r[] to $r. This ensured that i get individual arrays from the Item nodes. However, when i try to insert $r into Mysql table, each individual element of $r is inserted as a unique row see table below for the data structure:
+----+----------------------------------+
| id | dates |
+---------------------------------------+
| 1 | received Date 2015/11/08 00:00 |
| 2 | accepted Date 2016/04/16 00:00 |
| 3 | entrez Date 2016/08/31 06:00 |
| 4 | pubmed Date 2016/08/31 06:00 |
| 5 | medline Date 2016/08/31 06:00 |
| 6 | epublish Date 2016/05/23 00:00 |
| | |
| | |
| | |
+---------------------------------------+
What, i am trying to get is this data structure. see below:
+----+-------------------------------------------------------------------------------------------------+
| id | dates |
+------------------------------------------------------------------------------------------------------+
| 1 | received Date 2015/11/08 00:00, accepted Date 2016/04/16 00:00, entrez Date 2016/08/31 06:00 |
+-------------------------------------------------------------------------------------------------------+
When i
echo $r
i get this result(see below), but i am not able to get it into a table as a string. What am i doing wrong?
received Date 2015/11/08 00:00, accepted Date 2016/04/16 00:00, entrez Date 2016/08/31 06:00, pubmed Date 2016/08/31 06:00, medline Date 2016/08/31 06:00, epublish Date 2016/05/23 00:00