<?php

// create tables
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
date_default_timezone_set('Asia/Jakarta');
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');

/* fill in your database name */
$database_name = "vsilico1_lokon";
  
/* connect to MySQL */
if (!$link = mysql_connect("localhost", "vsilico1_lokon", "depok")) {
  die("Could not connect: " . mysql_error());
}

mysql_select_db($database_name) or die(mysql_error());

$sql = "CREATE TABLE IF NOT EXISTS `lkdatasetlayout` (
  `LkDataSetLayoutID` int(11) NOT NULL AUTO_INCREMENT,
  `DataSetID` int(11) NOT NULL,
  `LayoutID` int(11) NOT NULL,
  `RegionID` varchar(50) NOT NULL,
  `MediaID` varchar(50) NOT NULL,
  PRIMARY KEY (`LkDataSetLayoutID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ";

if(!$result = mysql_query($sql)){
  die("Error, could not create tables. MySQL Error: " . mysql_error());
}
  
$sql = "DESCRIBE lkdatasetlayout";
if(!$result = mysql_query($sql)){
  die("Error, could not describe tables. MySQL Error: " . mysql_error());
}

echo "<table border=1>";
echo "<tr><td>Field</td><td>Type</td><td>Null</td><td>Key</td><td>Default</td><td>Extra</td></tr>";
while($row = mysql_fetch_array($result)) {
    echo "<tr><td>{$row['Field']}</td><td>{$row['Type']}</td><td>{$row['Null']}</td><td>{$row['Key']}</td><td>{$row['Default']} </td><td>{$row['Extra']}</td></tr>" . EOL;
}
echo "</table>";

/* query all tables */
$sql = "UPDATE module SET RegionSpecific = '0' WHERE Module = 'datasetview'";
if(!$result = mysql_query($sql)){
  die("Error, could not update tables. MySQL Error: " . mysql_error());
}
  
/* query all tables */
$sql = "SELECT * FROM module WHERE Module = 'datasetview'";
if(!$result = mysql_query($sql)){
  die("Error, could not list tables. MySQL Error: " . mysql_error());
}
$assoc = mysql_fetch_assoc($result);
echo "<pre>";
echo var_dump($assoc);
echo "<pre>" . EOL;

echo 'END' . EOL;
?>