1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
| <?php
$pdo = new PDO('mysql:host=mon_ip;dbname=ma_base', 'id', '****');
?>
<!DOCTYPE html>
<head>
<title> .: zool.bzh :. Demo - Vision</title>
</head>
<body style="width: 980px" bgcolor=#FFFFFF>
<img src="pics/header.jpg" height="147" width="980">
<?php
$selected = isset( $_GET['dos'] ) ? $_GET['dos'] : "" ;
$selectedValue = 'selected="selected"';
?>
<form method="GET" action="index.php">
<select name="dos" id="dos" size="1">
<option value="Dossier1" <?php if( $selected == "Dossier1" ) echo $selectedValue ?>>Dossier1</option>
<option value="Dossier2" <?php if( $selected == "Dossier2" ) echo $selectedValue ?>>Dossier2</option>
<option value="Dossier3" <?php if( $selected == "Dossier3" ) echo $selectedValue ?>>Dossier3</option>
</select>
<?php
if (!isset($_GET['dos'])){
$dos="Dossier1";
} else {
$dos = $_GET['dos'];
}
if (isset($_GET['reset']) || isset($_GET['val']) || isset($dos)) {
$sql_less = 'SELECT min(height), max(height), min(width), max(width), name_tof, dos_tof FROM pictures WHERE dos_tof = :dos_tof';
$sth_less = $pdo->prepare($sql_less);
$sth_less->execute(array('dos_tof' => $dos));
$done_pics = $sth_less->fetchAll();
foreach ($done_pics as $pics_less) {
$min_height_value = $pics_less['min(height)'];
$max_height_value = $pics_less['max(height)'];
$min_width_value = $pics_less['min(width)'];
$max_width_value = $pics_less['max(width)'];
}
}
if (isset($_GET['minh']) && isset($_GET['maxh']) && isset($_GET['minw']) && isset($_GET['maxw']) && !isset($_GET['reset']) && !isset($_GET['val'])) {
$min_height_value = $_GET['minh'];
$max_height_value = $_GET['maxh'];
$min_width_value = $_GET['minw'];
$max_width_value = $_GET['maxw'];
}
?>
longueur entre<input type="text" name="minh" value="<?php echo $min_height_value ?>" size="4" maxlength="4">
et <input type="text" name="maxh" value="<?php echo $max_height_value ?>" size="4" maxlength="4">
largeur entre<input type="text" name="minw" value="<?php echo $min_width_value ?>" size="4" maxlength="4">
et <input type="text" name="maxw" value="<?php echo $max_width_value ?>" size="4" maxlength="4">
<input type="submit" name="val" value="Valider" />
<input type="submit" name="reset" value="reset" />
<?php
$sql_pics = 'SELECT height, width, dos_tof, name_tof FROM pictures WHERE dos_tof = :dos_tof AND height <= :sqlmaxheight AND height >= :sqlminheight AND width <= :sqlmaxwidth AND width >= :sqlminwidth';
$sth_pics = $pdo->prepare($sql_pics);
$sth_pics->execute(array('dos_tof' => $dos,
'sqlmaxheight' => $max_height_value,
'sqlminheight' => $min_height_value,
'sqlmaxwidth' => $max_width_value,
'sqlminwidth' => $min_width_value
));
$save_pics = $sth_pics -> fetchAll();
$nbr_line_pics = $sth_pics->rowCount();
?>
</form>
</div>
<div>
<?php
echo $nbr_line_pics." photos dans la base<br>";
foreach($save_pics as $pics) {
echo $pics['name_tof']."<br>";
}
?>
</div>
</body>
</html> |