<?php
	
final class Rs {
	
	private $sql;
	var $cleaner = '<div style="clear: both;"></div>';
	
	public function __construct() {
		global $sql;
		$this->sql = &$sql;
    }
		
	public function return_section() {
        $this->sql->sql_connect('e_learning');
		echo $sql_sekcie = 'SELECT * FROM categories WHERE id_parent=' . $_GET['id'];
		if ( $result_sekcie = mysql_query($sql_sekcie) ) {
			echo 'Sekcia:<br /><select onchange="loadSubject()" id="category" name="category">';
			echo 	'<option>--</option>';
			while ( $row_sekcie = mysql_fetch_assoc($result_sekcie) ) {

                if ( isset($_POST['category']) && ($_POST['category']==$row_sekcie['id_category']) ) {
                    $selected = 'selected="selected"';
                } else {
                    $selected = '';
                }
                echo '<option ' . $selected . ' value="p' . $row_sekcie['id_category'] . '">' . $row_sekcie['category'] . '</option>';

			}
			echo '</select><br />';
			//if ( isset($_POST['category']) ) {
				echo 'Predmet:<br /><select name="subject" id="subject">';
				/*echo 	'<option>--</option>';
				$sql_sub_subject = 'SELECT * FROM categories WHERE id_parent=' . $_POST['category'];
				if ( $result_sub_subject = mysql_query($sql_sub_subject) ) {
					while ( $row_sub_subject = mysql_fetch_assoc($result_sub_subject) ) {
						if ( isset($_POST['subject']) && ($_POST['subject']==$row_sub_subject['id_category']) ) {
							$selected2 = 'selected="selected"';
						} else {
							$selected2 = '';
						}
						echo '<option ' . $selected2 . ' value="' . $row_sub_subject['id_category'] . '">' . $row_sub_subject['category_alt'] . '</option>';
					}
				}*/
				echo '</select>';
			//}
		}
		echo '<br />';
	}
	
	public function add_article() {
		$this->sql->sql_connect('e_learning');
			
		$this->sql->sql_free_result($result_section);
		$this->sql->sql_close();
	}
	
}
?>