I am trying to transfer data from a MySQL database (with relational columns) to a markdown file (Pico CMS). For that I created the following SQL query to get the data:
SELECT DISTINCT
rqypj_mt_links.link_name,
rqypj_mt_links.link_desc,
rqypj_mt_links.address,
rqypj_mt_links.city,
rqypj_mt_links.state,
rqypj_mt_links.country,
rqypj_mt_links.postcode,
rqypj_mt_links.telephone,
rqypj_mt_links.fax,
rqypj_mt_links.email,
rqypj_mt_links.website,
rqypj_mt_links.price,
rqypj_mt_links.lat,
rqypj_mt_links.lng,
rqypj_mt_links.zoom,
rqypj_mt_cats.cat_name,
rqypj_mt_images.filename,
rqypj_mt_cfvalues.value,
rqypj_mt_customfields.caption
FROM rqypj_mt_links
LEFT JOIN rqypj_mt_cl
ON rqypj_mt_links.link_id = rqypj_mt_cl.link_id
LEFT JOIN rqypj_mt_cats
ON rqypj_mt_cl.cat_id = rqypj_mt_cats.cat_id
LEFT JOIN rqypj_mt_images
ON rqypj_mt_links.link_id = rqypj_mt_images.link_id
LEFT JOIN rqypj_mt_cfvalues
ON rqypj_mt_links.link_id = rqypj_mt_cfvalues.link_id
LEFT JOIN rqypj_mt_customfields
ON rqypj_mt_cfvalues.link_id = rqypj_mt_customfields.cf_id
ORDER BY rqypj_mt_links.link_id, rqypj_mt_cl.cat_id
LIMIT 100
This qives the following result
Title | desc | adress | cats | etc.
But when a title has multiple cats I get multiple rows with the same data only the cat row difference. Therefore I am looking for the best way to transfer the SQL data in to a PHP array. F.e.:
$result['title']
$result['desc']
$result['cats'][0]
$result['cats'][1]
Etc.
I guess that way it w'll be more easy to write the markdown file. Hopefully someone can get me some advise about the best approach and some PHP tips/scripts.
Thanks in advance! Jelte