|
Hi, am a relative newbie to php & mysql and am having a huge problem with one piece of code in my joomla site.
I have the following code:
$query = "SELECT #__listings2_cat_items_relations.catid,#__listings2_cat_items_relations.itemid,#__listings2_cats_relations.catid,#__listings2_cats_relations.parentid,#__listings2_item.itemid#__listings2_item.title FROM #__listings2_cat_items_relations LEFT JOIN catid ON #__listings2_cat_items_relations.catid = #__listings2_cats_relations.catid AND JOIN itemid ON #__listings2_cat_items_relations.itemid = #__listings2_item.itemid WHERE #__listings2_cats_relations.parentid = '3'";
$database->setQuery( $query );
//$parent_id = '#__listings2_cats_relations.parentid';
$cat_id = $database;
$title = $this->title;
if ($cat_id = 3) {
$statement = "INSERT INTO jos_jcalpro_venues (venue_id,venue_name,venue_link,color,bgcolor,options,level,published,checked_out,checked_out_time) VALUES ('', '$title', '', 'default', 'default', 0, 0, 1, 0, '0000-00-00 00:00:00')";
$database->setQuery($statement);
$database->query();
if ($database->getErrorNum())
$config->logSobiError('saveSobi():'.$database->stderr());
}
What is comes from is this...
I have one piece of the site where people can create directory listings, and another where people can list events in a calendar. What I need is for the listings entered for venues to appear as choices available for where the events can take place. The code above puts the right information from the listings into the new table called 'venues' in the calendar part of the database. Unfortunately it is inserting data on ALL the listings created, not just the venues. The venues all belong to categories that have a parent category 'venues' which is the id '3' in the code above. I know there is something seriously wrong with the way in which I'm filtering / sub-selecting the right records - can anyone help?
I've tried googling and searching a number of forums, but must not be searching for the right thing!
Thanks
Ali
|