<?php 

function add_city($name)
{
	$sql = "INSERT INTO ".TB_PREF."city (name) VALUES (".db_escape($name) .")";
   	db_query($sql,"The city group could not be added");
}

function update_city($selected_id, $name)
{
	$sql = "UPDATE ".TB_PREF."city SET name=".db_escape($name)." WHERE id = ".db_escape($selected_id);
   	db_query($sql,"The city group could not be updated");
}

function delete_city($selected_id)
{
	$sql="DELETE FROM ".TB_PREF."city WHERE id=".db_escape($selected_id);
	db_query($sql,"could not delete city group");
}

function get_citys($show_inactive)
{
	$sql = "SELECT * FROM ".TB_PREF."city";
	if (!$show_inactive) $sql .= " WHERE !inactive";
	return db_query($sql,"could not get city");
}

function get_city($selected_id)
{
	$sql = "SELECT * FROM ".TB_PREF."city WHERE id=".db_escape($selected_id);

	$result = db_query($sql,"could not get group");
	return db_fetch($result);
}

function get_city_name($id)
{
	$sql = "SELECT name FROM ".TB_PREF."city WHERE id = ".db_escape($id);
	$result = db_query($sql, "could not get group");
	$row = db_fetch($result);
	return is_array($row) ? $row[0] : false;
}

//-----------------------------------------------------------------------------------------------//

?>