I am trying to load all records from the database that have been created by the current logged on user in Joomla, im not sure if its possible to have php inside a mysql query though ?, if not how would I go about doing this otherwise ?
SELECT
leadname,
businessname,
postcode,
gasoiluser,
dervuser,
kerouser,
cf_uid,
cf_id
FROM
#__chronoforms_data_addupdatelead
WHERE createdby = '<?php
$user =& JFactory::getUser(); echo $user->get('name') ; ?>'
ORDER BY cf_created DESC
Of course you can access PHP variables for creating the query – as the
#__prefix suggests, you’re already running your query from “inside Joomla”. Which means it is in php, and something like this should do what you want:But a little more context would help us see what you’ll have to do exactly – what’s the code around the SQL query – is it in a php file?
Remember,
echoprints to the Response, which is not what you want to do in this case, you want to change the query; so just concatenate the variable content to your query, as shown above; and you should actually be already be in php mode where this query is defined, so the<?phptag is of no use (but again, too few context to be sure about this)!