<?
error_reporting(E_ALL);
include 'dbconnect.php';
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<body>
<?

/*
$dbh = new PDO("mysql:host=localhost;dbname=mmaaaco_ksecor", "username", "password here");

CREATE TABLE IF NOT EXISTS `contacts` (
  `fullname` varchar(255) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
*/

//Teaching CRUD!!!
//first let's insert!!!!!
//MUST LEARN INSERT STATEMENT..OTHERWISE HOW ARE YOU GOING TO GET DATA IN!!!! 
//create or insert is first
//insert into contacts (fullname) values ('Kris Secor');
$sql = $dbh->prepare("insert into contacts (fullname) values ('Kris Secor')");
$sql->execute();
//now for the read
$sql = $dbh->prepare("select fullname from contacts");
$sql->execute();
//this is how we display!!!!
while ($row = $sql->fetch()){
	echo $row['fullname'].'<br/>';
}
//this is update
$sql = $dbh->prepare("update contacts set fullname = 'Kristian Secor' where fullname = 'Kris Secor' ");
$sql->execute();
print_r($sql->errorInfo());
//this is the delete
$sql = $dbh->prepare("delete from contacts where fullname = 'Kristian Secor' "); 
$sql->execute();

?>
</body>
</html>
