OK Created a real database, and about to add the html code once i finish it. Note that the database name is the same, but i changed the table from tbl1 to NES (plan to add more databases for things like nes/ps1/GC/ext).
Database link (BG bucket was being a pain): https://drive.google.com/file/d/0B1A...it?usp=sharing
Database Format: varChar(25), varchar(6), smallint
Database output when running getdata.php
Code:
Array ( [0] => Array ( [Title] => Double Dragon [0] => Double Dragon [Rarity] => Common [1] => Common [NumCopies] => 1 [2] => 1 ) [1] => Array ( [Title] => TMNT Arcade [0] => TMNT Arcade [Rarity] => common [1] => common [NumCopies] => 1 [2] => 1 ) [2] => Array ( [Title] => Star Treck 25th [0] => Star Treck 25th [Rarity] => common [1] => common [NumCopies] => 1 [2] => 1 ) [3] => Array ( [Title] => TNMT [0] => TNMT [Rarity] => common [1] => common [NumCopies] => 1 [2] => 1 ) [4] => Array ( [Title] => Yoshi [0] => Yoshi [Rarity] => common [1] => common [NumCopies] => 1 [2] => 1 ) [5] => Array ( [Title] => Gauntlet [0] => Gauntlet [Rarity] => common [1] => common [NumCopies] => 1 [2] => 1 ) [6] => Array ( [Title] => Birthday Blowout [0] => Birthday Blowout [Rarity] => common [1] => common [NumCopies] => 1 [2] => 1 ) [7] => Array ( [Title] => Metal Geara [0] => Metal Geara [Rarity] => common [1] => common [NumCopies] => 1 [2] => 1 ) [8] => Array ( [Title] => Super Mario Bros 2 [0] => Super Mario Bros 2 [Rarity] => common [1] => common [NumCopies] => 1 [2] => 1 ) [9] => Array ( [Title] => Dynowarz [0] => Dynowarz [Rarity] => common [1] => common [NumCopies] => 1 [2] => 1 ) [10] => Array ( [Title] => Mission: Impossible [0] => Mission: Impossible [Rarity] => common [1] => common [NumCopies] => 1 [2] => 1 ) [11] => Array ( [Title] => Star trek next Generation [0] => Star trek next Generation [Rarity] => rare [1] => rare [NumCopies] => 1 [2] => 1 ) [12] => Array ( [Title] => Bionic Commando [0] => Bionic Commando [Rarity] => common [1] => common [NumCopies] => 1 [2] => 1 ) [13] => Array ( [Title] => ice hokey [0] => ice hokey [Rarity] => common [1] => common [NumCopies] => 1 [2] => 1 ) [14] => Array ( [Title] => dragon spirit [0] => dragon spirit [Rarity] => common [1] => common [NumCopies] => 1 [2] => 1 ) [15] => Array ( [Title] => Ghost N Goblins [0] => Ghost N Goblins [Rarity] => rare [1] => rare [NumCopies] => 1 [2] => 1 ) [16] => Array ( [Title] => Super Mario Bros [0] => Super Mario Bros [Rarity] => common [1] => common [NumCopies] => 1 [2] => 1 ) [17] => Array ( [Title] => Mega Man: 4 [0] => Mega Man: 4 [Rarity] => rare [1] => rare [NumCopies] => 1 [2] => 1 ) [18] => Array ( [Title] => Sky Shark [0] => Sky Shark [Rarity] => common [1] => common [NumCopies] => 1 [2] => 1 ) [19] => Array ( [Title] => Wrestle mania [0] => Wrestle mania [Rarity] => common [1] => common [NumCopies] => 1 [2] => 1 ) [20] => Array ( [Title] => Gremlins 2 [0] => Gremlins 2 [Rarity] => common [1] => common [NumCopies] => 1 [2] => 1 ) [21] => Array ( [Title] => top gun [0] => top gun [Rarity] => common [1] => common [NumCopies] => 1 [2] => 1 ) [22] => Array ( [Title] => tetris [0] => tetris [Rarity] => common [1] => common [NumCopies] => 1 [2] => 1 ) [23] => Array ( [Title] => rescue the embassy mission [0] => rescue the embassy mission [Rarity] => common [1] => common [NumCopies] => 1 [2] => 1 ) [24] => Array ( [Title] => pinball [0] => pinball [Rarity] => common [1] => common [NumCopies] => 1 [2] => 1 ) [25] => Array ( [Title] => Hook [0] => Hook [Rarity] => common [1] => common [NumCopies] => 1 [2] => 1 ) [26] => Array ( [Title] => Nightmare on Elm Street [0] => Nightmare on Elm Street [Rarity] => Rare [1] => Rare [NumCopies] => 1 [2] => 1 ) [27] => Array ( [Title] => Captian Sky Hawk [0] => Captian Sky Hawk [Rarity] => common [1] => common [NumCopies] => 1 [2] => 1 ) [28] => Array ( [Title] => Play Action Football [0] => Play Action Football [Rarity] => common [1] => common [NumCopies] => 1 [2] => 1 ) )
HTML Code:
Code:
<html>
<head>
<link id="pagestyle" href="style.css" rel="stylesheet" type="text/css">
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="js/dw_event.js" type="text/javascript"></script>
<script src="js/dw_rotator.js" type="text/javascript"></script>
<script type="text/javascript">
var rotator1 = {
path: 'images/',
id: 'r1', // id of image that rotates
speed: 3000, // default 4500
images: ["nes.jpg", "snes.jpg", "n64.jpg", "gc.jpg"]
}
function initRotator() {
dw_Rotator.setup(rotator1);
}
dw_Event.add( window, 'load', initRotator);
</script>
</head>
<body>
<div id="header">
<h1>Retro Game Collection</h1>
</div>
<div id="body">
<img id="r1" src="images/nes.jpg" alt="">
<h1>NES Titles</h1>
<div id="contentBox" style="margin:0px auto; width:100%">
<div id="column1" style="float:left; margin:3; width:30%;">
content (scrolls overflow)
</div>
<div id="column2" style="float:left; margin:3;width:30%;">
content (scrolls overflow)
</div>
<div id="column3" style="float:left; margin:3;width:30%;">
content (scrolls overflow)
</div>
</div>
<?php
// Specify your sqlite database name and path //
$dir = 'sqlite:NESCollection.db';
// Instantiate PDO connection object and failure msg //
$dbh = new PDO($dir) or die("cannot open database");
// Define your SQL statement, myTable = table name in your DB //
$sql = "SELECT * FROM NES";
// Apply statement //
$statement = $dbh->query($sql);
// Fetch the results //
$rowset = $statement->fetchAll();
// Show the results //
echo json_encode($rowset);
?>
</div>
</body>
</html>
Running the page works perfectly, excluding the format. My Results:
In a unrelated note and im sure its a simple fix just haven't messed with it much I would like the webpage to fill the screen instead of being limited to the specified size by the style sheet, but still maintain the ratios defined by the style sheet. But not actively seeking help with this, last on my priority list and haven't actively been trying to fix it, but if its a simple change this line to this plz let me know lol.
Style sheet:
Code:
#container {
width: 900px;
}
#header {
width: 900px;
height:50px;
font-style: oblique;
color: Red;
background-color: #C0C0C0;
border-bottom: 2px solid #000000;
}
#leftnav {
float: left;
width: 160px;
height: 500px;
background-color: #C0C0C0;
border-right: 2px solid #000000;
}
#body {
width: 900px;
height: 1000px;
color: red;
background-color: #C0C0C0;
}
#footer {
wiidth: 900px;
height: 50px;
background-color: #C0C0C0;
color: Red;
border-top: 2px solid #000000;
}
#CompleteFont {
color: green;
}
#RareFont {
color: red;
}
#Column1 {
overflow: Scroll;
height:300px;
width: 100px;
border: 1px solid black;
}
#Column2 {
overflow: Scroll;
height:300px;
width: 100px;
border: 1px solid black;
}
#Column3 {
overflow: Scroll;
height:300px;
width: 100px;
border: 1px solid black;
}
And the last thing that is kind of bothering me. When I went to create the database I tried to define create the nes table as such:
Code:
Create Table NES (Title varchar(25), Rarity varChar(6), Obtained varChar(3));
But everytime i got a syntax error around ); why is that? I changed obtained varChar(3) to smallint and it worked fine (and in hind site this works better) but what was I doing wrong?