How to use variable in Mysql WHARE Clause

hanees

New Member
I use the following code to filter dropdown menu in 'Joins where and/or
order by statement (SQL)
' section. but it is not loading.

$user =& JFactory::getUser();
WHERE name = '".$user ."'
 
WHERE name = '".$user ."' is not working without defining $user. so where to define $user to work it. or how to use {tablename___elementname} in (WHERE name = '".$user ."' ).
 
yes. its working. thank you so much.

i have another requirement . that is i have a form with a field element with label of student id and another drop down element called subject. this student id field automatically get its value from browser URL. my requirement is when loading this form, the subject drop down filters the items depends on student id. how to do it using 'Joins where and/or order by statement (SQL)' section or other method?
I tried with {tablename___studenid}. but not working.
 
You can use a cascading dropdown element linked to your subject. Then in your settings for the CDD, you setup the "Watch" tab which connects to your student_id.

The CDD basically watches the value of student_id, and if it changes, then the CDD will filter the list according to the value in student_id
 
You can do it either way. With a CDD, or with a join with a WHERE filter and AJAX enabled on that. I suspect the problem with "I tried with {tablename___studenid}. but not working" is that you would need to use the _raw placeholder for studentid. All element types that have the concept of 'value' and 'label' (like joins, checkboxes, radios, etc), when you want the value rather than the label in a placeholder, you need to append _raw, so {tablename___studentid_raw}. Otherwise you get "Joe Blow" (label) rather than "123" (id value).

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top