<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
	    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	</head>
	<body>
<?php
echo '<br /><form action="setup.php" method="post"><input type="submit" name="vytvortabulky" value="Vytvoriť tabuľky">';

if (file_exists('funkcie.php')) { include ('funkcie.php'); }

if(isset($_POST['vytvortabulky'])){
	if ($link = spoj_s_db()) {
		$sql =	"CREATE TABLE forum_pouzivatelia (
  id mediumint(7) NOT NULL auto_increment,
  meno varchar(20) collate utf8_unicode_ci NOT NULL,
  nick varchar(20) collate utf8_unicode_ci NOT NULL,
  heslo varchar(20) collate utf8_unicode_ci NOT NULL,
  mail varchar(20) collate utf8_unicode_ci NOT NULL,
  sex tinyint(1) NOT NULL,
  nazov_fora varchar(40) collate utf8_unicode_ci NOT NULL,
  skin tinyint(1) NOT NULL default '1',
  foto varchar(20) collate utf8_unicode_ci NOT NULL default 'nophoto.jpg',
  nar varchar(10) collate utf8_unicode_ci NOT NULL default 'none',
  nar_r smallint(4) NOT NULL,
  nar_m tinyint(2) NOT NULL,
  nar_d tinyint(2) NOT NULL,
  icq varchar(20) collate utf8_unicode_ci NOT NULL default 'none',
  mobil varchar(20) collate utf8_unicode_ci NOT NULL default 'none',
  PRIMARY KEY  (id),
  UNIQUE KEY nick (nick)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
		$result = mysql_query($sql, $link);
	
		$sql1 = "CREATE TABLE forum_priatelia (
  moje_id mediumint(6) NOT NULL,
  tvoje_id mediumint(6) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
		$result1 = mysql_query($sql1, $link);
		
		$sql2 = "CREATE TABLE forum_prispevky (
  id_prispevku mediumint(6) NOT NULL auto_increment,
  id_temy mediumint(6) NOT NULL,
  id_fora mediumint(6) NOT NULL,
  autor varchar(20) collate utf8_unicode_ci NOT NULL,
  sprava varchar(1000) collate utf8_unicode_ci NOT NULL,
  sprava_orig varchar(1000) collate utf8_unicode_ci NOT NULL,
  PRIMARY KEY  (id_prispevku)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
";
		$result2 = mysql_query($sql2, $link);
	
		$sql3 = "CREATE TABLE forum_temy (
  id_temy mediumint(6) NOT NULL auto_increment,
  id_fora mediumint(6) NOT NULL,
  tema varchar(5000) collate utf8_unicode_ci NOT NULL,
  tema_orig varchar(50) collate utf8_unicode_ci NOT NULL,
  popis varchar(5000) collate utf8_unicode_ci NOT NULL default 'None',
  popis_orig varchar(500) collate utf8_unicode_ci NOT NULL default 'None',
  prezrete varchar(4) collate utf8_unicode_ci NOT NULL default '?',
  autor varchar(20) collate utf8_unicode_ci NOT NULL,
  posledny varchar(200) collate utf8_unicode_ci NOT NULL,
  pristupnost tinyint(1) NOT NULL default '1',
  PRIMARY KEY  (id_temy)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
";
		$result3 = mysql_query($sql3, $link);
	
		if($result && $result1 && $result2 && $result3)
			echo ' Tabuľky v databáze boli úspešne vytvorené!';
		else
			echo ' Tabuľky v databáze sa nepodarilo vytvoriť!';
	}	
}
echo '</form><hr /><br />';
?>					
	</body>
</html>