By default
$query->where($condition)
appends conditions using an AND when you use several where's. So your code will produce something like
campusid = XX AND courseid = YY AND campusid = XX AND courseid = ZZ ...
So it doesn't work because courseid cannot be YY and ZZ at the same time.
You use a trick to solve this, using explode
but before exploding, we must sanitize the received data.
This code is not tested :
$tmpIds = array();
foreach($courseID as $cId){
$tmpIds[] = $db->quote($cId); // sanitize the input
}
$courseID1 = explode($tmpIds,",");
$query->select($db->quoteName('startdate'));
$query->from($db->quoteName('intake'));
$query->where($db->quoteName('campusid').'='. $db->quote($campusID));
$query->where($db->quoteName('courseid').' IN ('. $courseID1 . ')';
// Set the query for the DB oject to execute
$db->setQuery($query);
// Get the DB object to load the results as a list of objects
$results = $db->loadObjectList();
if($result){
echo "GOOD";
} else {
echo "Error";
}
As pointed on the notes below, you should avoid using $_POST, $_GET, $_FILES, etc... directly. Since Joomla! 2.5 JInput class (on 1.5 to 1.7 this was done with JRequest) is provided to access those variables.
Regards,