<?php


session_start();
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json");

if($_SESSION['dbName']==""){
header("location:../index.php");
}

include("../config.inc.php");

set_time_limit(0);

$connection = mysql_connect($config['dbServer'],$config['dbUser'],$config['dbPass']) or die("Could not connect to DB");
mysql_select_db($_SESSION['dbName'],$connection) or die("Could not find DB");
if(	$_SESSION['encodingmode'] == 'utf8' || $_SESSION['encodingmode'] == 'utf-8'){
	mysql_query("SET NAMES 'utf8'"); 
	mysql_query('SET CHARACTER SET utf8'); 
	mysql_set_charset('utf8', $connection);
}

$select = "SELECT item_code FROM items ";

    // Codierung
    

    //SQL-Befehl in Variable speichern
  $sql=mysql_query($select,$connection) or die(mysql_error());

    //Array erstellen
  $myArr = array();

    while ($row = mysql_fetch_array($sql)){ 
	 extract($row);
	 
	//echo "here"; 	
       array_push($myArr,$item_code);
    }

$myJSON = json_encode($myArr);

echo $myJSON;
	 
 

?>

