$dbh = new PDO("mysql:host=localhost;dbname=mmaaaco_ksecor", "mmaaaco_ksecor", "#ANV67ZyLTIh");
/*
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');
$submit = $_POST['submit'];
if ($submit == 'Submit') {
$fullname = $_POST['name'];
$sql = $dbh->prepare("insert into contacts (fullname) values ('$fullname')");
$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'].'
';
}
//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();
?>