Location: PHPKode > projects > PortalXP - Teacher Edition > PortalXP/PortalXP/admin/install.php
<?PHP

require('config.php');
require('connect.php');

?>

<TITLE>PortalXP Installer</TITLE>

<div style="POSITION: absolute; TOP: 125px; LEFT: 5px;  width: 650px; Z-INDEX: 25">

<h3>Install Database</h3><p>

<?php

if ($submit) {

//process form

$conn = mysql_connect("$hostname","$user", "$password");

//$query = "CREATE DATABASE $database";
mysql_create_db("$database");

$query1 = "
CREATE TABLE assignments (
  assignments_id int(11) NOT NULL auto_increment,
  teacher_id int(11) default NULL,
  periods_id int(11) default NULL,
  download_id int(11) default '0',
  points text,
  datedue text,
  description text,
  shortname text,
  visible tinyint(4) NOT NULL default '0',
  KEY assignments_id (assignments_id)
) TYPE=MyISAM";
# --------------------------------------------------------

#
# Table structure for table `calendar`
#

$query2 = "
CREATE TABLE calendar (
  id int(11) NOT NULL auto_increment,
  teacher_id int(11) default NULL,
  stamp datetime default NULL,
  timeofday text,
  subject varchar(255) default NULL,
  description text,
  PRIMARY KEY  (id)
) TYPE=MyISAM";
# --------------------------------------------------------

#
# Table structure for table `district`
#

$query3 = "
CREATE TABLE district (
  district_id int(11) NOT NULL auto_increment,
  districtname text,
  districtaddress text,
  districtphone text,
  KEY district_id (district_id)
) TYPE=MyISAM";
# --------------------------------------------------------

#
# Table structure for table `downloads`
#

$query4 = "
CREATE TABLE downloads (
  download_id int(11) NOT NULL auto_increment,
  teacher_id int(11) default NULL,
  filename text,
  uploaddate timestamp(8) NOT NULL,
  KEY download_id (download_id)
) TYPE=MyISAM";
# --------------------------------------------------------

#
# Table structure for table `links`
#

$query5 = "
CREATE TABLE links (
  links_id int(11) NOT NULL auto_increment,
  teacher_id int(11) default NULL,
  website text,
  displayname text,
  link_description text,
  KEY links_id (links_id)
) TYPE=MyISAM";
# --------------------------------------------------------

#
# Table structure for table `news`
#

$query6 = "
CREATE TABLE news (
  news_id int(11) NOT NULL auto_increment,
  teacher_id int(11) default NULL,
  postdate timestamp(8) NOT NULL,
  subject text,
  message text,
  KEY news_id (news_id)
) TYPE=MyISAM";
# --------------------------------------------------------

#
# Table structure for table `periods`
#

$query7 = "
CREATE TABLE periods (
  periods_id int(11) NOT NULL auto_increment,
  teacher_id int(11) default NULL,
  hournumber text,
  starttime text,
  endtime text,
  classname text,
  periodsnotes text,
  course text,
  periodorder int(11) default NULL,
  KEY periods_id (periods_id)
) TYPE=MyISAM";
# --------------------------------------------------------

#
# Table structure for table `school`
#

$query8 = "
CREATE TABLE school (
  school_id int(11) NOT NULL auto_increment,
  schoolname text,
  schooladdress text,
  schoolphone text,
  schoolemail text,
  KEY school_id (school_id)
) TYPE=MyISAM";
# --------------------------------------------------------

#
# Table structure for table `teacher`
#

$query9 = "
CREATE TABLE teacher (
  teacher_id int(11) NOT NULL auto_increment,
  school_id int(11) default NULL,
  district_id int(11) default NULL,
  title text,
  lastname text,
  firstname text,
  phone text,
  email text,
  teacherpass text,
  theme_id int(11) NOT NULL default '1',
  classrules text,
  KEY teacher_id (teacher_id)
) TYPE=MyISAM";
# --------------------------------------------------------

#
# Table structure for table `theme`
#

$query10 = "
CREATE TABLE theme (
  theme_id int(11) NOT NULL auto_increment,
  themename text,
  topname text,
  topaddress text NOT NULL,
  toprow text NOT NULL,
  classrow text NOT NULL,
  linksrow text NOT NULL,
  contentrow text NOT NULL,
  bottomrow text NOT NULL,
  sidemenu text NOT NULL,
  KEY theme_id (theme_id)
) TYPE=MyISAM";

$query11 = "
INSERT INTO theme VALUES (1, 'Default - Green', '#008000', '#FF0000', '#349601', '#349601', '#349601', '#349601', '#349601', '#85BA69')";

$query12 = "
INSERT INTO theme VALUES (2, 'blue', '00627E', '00627E', '00627E', '00627E', '00627E', '00627E', '00627E', '7489D4')";

$query13 = "
INSERT INTO theme VALUES (3, 'Black/Gold', '000000', '000000', '000000', 'C3A100', 'C3A100', 'C3A100', '000000', 'C3A100')";


 mysql_select_db($database);
 $result = mysql_query($query);
 $result1 = mysql_query($query1);
 $result2 = mysql_query($query2);
 $result3 = mysql_query($query3);
 $result4 = mysql_query($query4);
 $result5 = mysql_query($query5);
 $result6 = mysql_query($query6);
 $result7 = mysql_query($query7);
 $result8 = mysql_query($query8);
 $result9 = mysql_query($query9);
 $result10 = mysql_query($query10);
 $result11 = mysql_query($query11);
 $result12 = mysql_query($query12);
 $result13 = mysql_query($query13);




 if($result1) {
  echo " Created Database <br> Created tables<br>";
 } else {
   echo " Error Creating Tables<br>";
 }

echo "The database has been created.\n"; 

} else {

//display form

?>

<form method="post" action="<?php echo $PHP_SELF?>">

Install Checklist<p>

<input type="Submit" name="submit" value="Click to Install">

</form>

<?php

}  //end if

?>

</div>
Return current item: PortalXP - Teacher Edition