I want to wirte a small php file, which will convert a results from mysql into a given XML template , on a production site.So what i did (before i knew how the site DB is constructed), i've written a very small mock DB with one table and tested my script, and it seemed to work , here is a sniplet from the table and the script
+----+---------------+----------------------------+--------+
| id | house | time_cr | price |
+----+---------------+----------------------------+--------+
| 1 | Villa_Niki | 2015-01-13 13:23:56.543294 | 25000 |
| 2 | toni | 2015-01-13 13:24:31.133273 | 34000 |
| 3 | kolio | 2015-01-13 13:26:06.720740 | 10000 |
| 4 | aldomirovvtxi | 2015-01-13 13:26:24.226741 | 100000 |
+----+---------------+----------------------------+--------+
then the script fetched the data into the XML ,quite straightforward
$kol=$xml->addChild('realty');
while($row=mysql_fetch_array($result))
{
$kol->addChild('id',$row["id"]);
$kol->addChild('creation-date',$row["time_cr"]);
$kol->addChild('last-update-date',$row["time_cr"]);
$kol->addChild('url','leva');
$kol->addChild('bldtype',$row["house"]);
........
so just using the fetch_array and then using the column indexes and looping was fine
yesterday i have opened the database on the Site, and it turned out that they put all the information not in a separate column, like for example separate column for City, State, etc. but instead they put all the information in a single column ,like this:
so is there a simple way to make it work in this case, like for a given specific listingsdb_id, to fetch the Street into the street XML tag , Area into the area XML tag etc ? All suggestions are welcome, thanks !
No comments:
Post a Comment