I'm combining 2 pieces of code that has been written by others. The page displays records from a mySql database and the variable I'm trying to use is already being displayed using the following code:
<span class="headLeft"><?php echo cleanData($this->RECIPE->name); ?>:</span>
The sql select statement is trying to use the name field for it's lookup.
SELECT
name
, Round(Sum(i.calories)/1500*100,2) as calories
, Round(Sum(protein)/525*100,2) as protein
, Round(Sum(fat)/300*100,2) as fat
, Round(sum(carbohydrate)/675*100,2) as carbohydrate
, Round(sum(fiber)/30*100,2) as fiber
, Round(sum(sugar)/375*100,2) as sugar
, Round(sum(saturated_fat)/150*100,2) as saturated_fat
, Round(sum(monounsaturated_fat)/150*2,2) as monsaturated_fat
, Round(sum(Polyunsaturated_Fat)/150*2,2) as polyunsaturated_fat
, Round(sum(cholesterol)/200*100,2) as cholesterol
, Round(sum(sodium)/1300*100,2) as sodium
FROM `mr_recipes` r
left join ingredients i on r.id = i.recipeid
where name = ($this->RECIPE->name)
group by name
I can't quite get the variable to work. I can't use $name and I've tried wrapping it in single and double quotes.