<?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 $key => $value){
				$type = $result->getColumnMeta($ii);
				if ($value != NULL){
					if (!in_array($key, $arr_keys)) array_push($arr_keys, $key);
					switch($type['native_type']){
						case 'BLOB': 
							if (!isset(${$key})){
								${$key} = stripcslashes(str_replace("'", "&#39;", str_replace("<br />","",str_replace("<br>","\n", $value))));
							} else if (isset(${$key}) && ${$key} != stripcslashes(str_replace("'", "&#39;", str_replace("<br />","",str_replace("<br>","\n", $value))))){
								${$key} = 'undefined';
							}
							break;
						case 'LONGLONG':
						case 'LONG':
						case 'SHORT':
							if (!isset(${$key})){
								${$key} = $value;
							} else if (isset(${$key}) && ${$key} != $value){
								${$key} = 'undefined';
							}
							break;
						case 'NEWDECIMAL':
						case 'FLOAT':
						case 'DOUBLE':
							if (!isset(${$key})){
								${$key} = str_replace(".", ",", $value);
							} else if (isset(${$key}) && ${$key} != str_replace(".", ",", $value)){
								${$key} = 'undefined';
							}
							break;
						default:
							if (!isset(${$key})){
								${$key} = stripcslashes(str_replace("'", "&#39;", $value));
							} else if (isset(${$key}) && ${$key} != stripcslashes(str_replace("'", "&#39;", $value))){
								${$key} = 'undefined';
							}
							break;
					}
				} else {
					if (!isset(${$key})){
						${$key} = $value;
					} else if (isset(${$key}) && ${$key} != $value){
						${$key} = 'undefined';
						if ($key == 'language') ${$key} = NULL;
					}
				}
				$ii++;
			}
		}
		foreach ($arr_keys AS $key){
			if (isset(${$key}) && ${$key} == 'undefined') ${$key} = NULL;
		}
		
	}
}