esercizi su mysql, box model, cookie e sessioni
This commit is contained in:
88
php12_mysql.php
Normal file
88
php12_mysql.php
Normal file
@@ -0,0 +1,88 @@
|
||||
|
||||
<?php
|
||||
|
||||
require_once ('functions.php');
|
||||
include('header.html');
|
||||
|
||||
///////////////////////////
|
||||
echo<<<_css
|
||||
|
||||
<style>
|
||||
|
||||
input:valid {
|
||||
background-color:green;
|
||||
}
|
||||
|
||||
input:invalid {
|
||||
background-color:red;
|
||||
}
|
||||
|
||||
input:in-range {
|
||||
font-size:20pt;
|
||||
}
|
||||
|
||||
input:required {
|
||||
color:red;
|
||||
}
|
||||
input:optional {
|
||||
color:blue;
|
||||
}
|
||||
|
||||
input:active {
|
||||
outline: 5px black solid;
|
||||
}
|
||||
|
||||
input:focus {
|
||||
outline: 5px yellow solid;
|
||||
}
|
||||
|
||||
|
||||
#a[placeholder="mario"][required]{
|
||||
outline: 5px red solid;
|
||||
}
|
||||
|
||||
|
||||
</style>
|
||||
_css;
|
||||
echo "\n";
|
||||
///////////////////////////
|
||||
|
||||
$db = new PDO ("mysql:host=localhost;dbname=phptest","root","alfiobello",array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
|
||||
//$db->query("INSERT INTO persone VALUES('mario','gino','2')");
|
||||
|
||||
try{
|
||||
$statement = $db->prepare("INSERT INTO persone VALUES(:a,:b,:c)");
|
||||
$statement->execute(array("a"=>"alfio","b"=>"giulio","c"=>"45"));
|
||||
}
|
||||
catch (Exception $e){}
|
||||
|
||||
|
||||
$statement = $db->prepare("SELECT * FROM persone p where p.eta > 1");
|
||||
$statement->execute();
|
||||
|
||||
while ($row = $statement->fetch())
|
||||
foreach($row as $key => $value)
|
||||
echo $value," \n<br>";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
include ('footer.html');
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user