<?php
if ((!isset($_POST['submit']) && isset($ids)) OR (isset($_POST['submit']) && $_POST['submit'] != 'reload' && isset($ids) && !isset($fehler))){
	$sql = "SELECT * FROM ".$multi_module." WHERE id IN ($ids) ";
	$result = $conn->prepare($sql);
	$result->execute();
	$arr_keys = array();
	if ($result->rowCount()){
		while ($arr = $result->fetch()){
			$ii = 0;
			foreach ($arr AS $db_key => $db_value){
				$db_column_meta = $result->getColumnMeta($ii);
				if ($db_value != NULL){
					if (!in_array($db_key, $arr_keys)) array_push($arr_keys, $db_key);
					switch($db_column_meta['native_type']){
						case 'BLOB': 
							if (!isset(${$db_key})){
								${$db_key} = stripcslashes(str_replace("'", "&#39;", str_replace("<br />","",str_replace("<br>","\n", $db_value))));
							} else if (isset(${$db_key}) && ${$db_key} != stripcslashes(str_replace("'", "&#39;", str_replace("<br />","",str_replace("<br>","\n", $db_value))))){
								${$db_key} = 'undefined';
							}
							break;
						case 'LONGLONG':
						case 'LONG':
						case 'SHORT':
							if (!isset(${$db_key})){
								${$db_key} = $db_value;
							} else if (isset(${$db_key}) && ${$db_key} != $db_value){
								${$db_key} = 'undefined';
							}
							break;
						case 'NEWDECIMAL':
						case 'FLOAT':
						case 'DOUBLE':
							if (!isset(${$db_key})){
								${$db_key} = str_replace(".", ",", $db_value);
							} else if (isset(${$db_key}) && ${$db_key} != str_replace(".", ",", $db_value)){
								${$db_key} = 'undefined';
							}
							break;
						default:
							if (!isset(${$db_key})){
								${$db_key} = stripcslashes(str_replace("'", "&#39;", $db_value));
							} else if (isset(${$db_key}) && ${$db_key} != stripcslashes(str_replace("'", "&#39;", $db_value))){
								${$db_key} = 'undefined';
							}
							break;
					}
				} else {
					if (!isset(${$db_key})){
						${$db_key} = $db_value;
					} else if (isset(${$db_key}) && ${$db_key} != $db_value){
						${$db_key} = 'undefined';
						if ($db_key == 'language') ${$db_key} = NULL;
					}
				}
				$ii++;
			}
		}
		foreach ($arr_keys AS $db_key){
			if (isset(${$db_key}) && ${$db_key} == 'undefined') ${$db_key} = NULL;
		}
		
	}
}