Forum Moderators: open
$sql = "SELECT p.*, a.id AS agentid, a.name AS agent, a.user AS user, c.name AS company, c.id AS companyid, t.name AS type, p.type AS typeid "
. "\n FROM (#__hp_properties AS p, #__hp_companies AS c)"
. "\n LEFT JOIN #__hp_agents AS a ON p.agent = a.id"
. "\n LEFT JOIN #__hp_prop_types AS t ON p.type = t.id"
. "\n LEFT JOIN #__hp_featured AS f ON f.property = p.id"
. "\n WHERE p.published='1' AND p.approved='1' AND t.published='1'"
.(count( $where )? " AND " . implode( ' AND ', $where ) : "")
.(($which == "featured")? "\nAND p.featured='1' AND p.type='". $idtype."" : "")
Now if on the last line I have:
.(($which == "featured")? "\nAND p.featured='1' AND p.type='1'" : "")
I get the results I am looking for with p.type='1'
I want to be able to bring in the changing variable from above though, the $idtype. What can I do to fix it so that it will show p.type=$idtype with correct syntax?
Is my syntax wrong?
Did you get this figured out? The query as you have it written is missing the last apostrophe as the others have suggested. You can troubleshoot errors such as these much easier if you dump your query to the browser, too. Here is what the last line looks like when we dump it out:
$sql = (statment here);
print '<pre>'; print($sql); exit('</pre>');
// AND p.featured='1' AND p.type='1