I hate MySQL!
I've now got as far as:
I have no idea how to do the WHERE clause.PHP Code:<?php
$links = $db->query('SELECT L.*, C.name AS category FROM links AS L INNER JOIN categories AS C ON C.id = L.category_id');
foreach($links as $link) {
array_push($link['websites'], $db->query("SELECT * FROM websites WHERE `table` IS 'links' AND `record_id` = " . $link['id']));
array_push($link['adverts' ], $db->query("SELECT * FROM adverts WHERE `table` IS 'links' AND `record_id` = " . $link['id']));
}
?>
It gives the error:
Fatal error: Problem preparing query (SELECT * FROM websites WHERE `table` IS 'links' AND `record_id` = 1) 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 ''links' AND `record_id` = 1' at line 1



Reply With Quote

Bookmarks