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 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
| <?php require_once('../Connections/form_boutique.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
// On détermine si les deux variables existent avec isset()
// Modifier $_POST[''] par $_GET[''] en fonction de la méthode utilisée dans le formulaire
if ((isset($_POST['coltheme'])) && (isset($_POST['colplateforme']))) {
if ($_POST['coltheme'] <> "Votre choix") { // Si $_POST['coltheme'] est différent de "Votre choix"
$coltheme = $_POST['coltheme'];
} else { // Sinon la variable $coltheme est égale à toutes les valeurs avec le signe "%"
$coltheme = "%";
}
if ($_POST['colplateforme'] <> "Votre choix") { // Même chose
$colplateforme = $_POST['colplateforme'];
} else {
$colplateforme = "%";
}
// On effectue notre SELECT avec LIKE ce qui permet de n'avoir qu'une requète
$colplateforme_jeux = "-1";
if (isset($colplateforme)) {
$colplateforme_jeux = $colplateforme;
}
$coltheme_jeux = "-1";
if (isset($coltheme)) {
$coltheme_jeux = $coltheme;
}
mysql_select_db($database_form_boutique, $form_boutique);
$query_jeux = sprintf("SELECT * FROM jeux WHERE theme LIKE %s AND plateforme LIKE %s", GetSQLValueString($coltheme_jeux, "text"),GetSQLValueString($colplateforme_jeux, "text"));
$jeux = mysql_query($query_jeux, $form_boutique) or die(mysql_error());
$row_jeux = mysql_fetch_assoc($jeux);
$totalRows_jeux = mysql_num_rows($jeux);
}
mysql_select_db($database_form_boutique, $form_boutique);
$query_theme = "SELECT DISTINCT theme FROM jeux";
$theme = mysql_query($query_theme, $form_boutique) or die(mysql_error());
$row_theme = mysql_fetch_assoc($theme);
$totalRows_theme = mysql_num_rows($theme);
mysql_select_db($database_form_boutique, $form_boutique);
$query_plateforme = "SELECT DISTINCT plateforme FROM jeux";
$plateforme = mysql_query($query_plateforme, $form_boutique) or die(mysql_error());
$row_plateforme = mysql_fetch_assoc($plateforme);
$totalRows_plateforme = mysql_num_rows($plateforme);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Document sans titre</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="essai_recherches.php">
<label>
<select name="theme" id="theme">
<option value="Votre choix">Votre choix</option>
<?php
do {
?>
<option value="<?php echo $row_theme['theme']?>"><?php echo $row_theme['theme']?></option>
<?php
} while ($row_theme = mysql_fetch_assoc($theme));
$rows = mysql_num_rows($theme);
if($rows > 0) {
mysql_data_seek($theme, 0);
$row_theme = mysql_fetch_assoc($theme);
}
?>
</select>
</label>
<label>
<select name="plateforme" id="plateforme">
<option value="Votre choix">Votre choix</option>
<?php
do {
?><option value="<?php echo $row_plateforme['plateforme']?>"><?php echo $row_plateforme['plateforme']?></option>
<?php
} while ($row_plateforme = mysql_fetch_assoc($plateforme));
$rows = mysql_num_rows($plateforme);
if($rows > 0) {
mysql_data_seek($plateforme, 0);
$row_plateforme = mysql_fetch_assoc($plateforme);
}
?>
</select>
</label>
<label>
<input type="submit" name="button" id="button" value="Envoyer" />
</label>
</form>
<?php do { ?>
<p><img src="<?php echo "../". $row_jeux['image']; ?>" /></p>
<p><?php echo $row_jeux['titre']; ?><br />
<?php echo $row_jeux['plateforme']; ?><br />
<?php echo $row_jeux['editeur']; ?><br />
<?php echo $row_jeux['theme']; ?></p>
<?php } while ($row_jeux = mysql_fetch_assoc($jeux)); ?></body>
</html>
<?php
mysql_free_result($jeux);
mysql_free_result($theme);
mysql_free_result($plateforme);
?> |
Partager