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 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
| <?php require_once('Connections/bdn.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$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;
}
}
mysql_select_db($database_bdn, $bdn);
$query_base_motorisation = "SELECT * FROM motorisation ORDER BY type_moteur ASC";
$base_motorisation = mysql_query($query_base_motorisation, $bdn) or die(mysql_error());
$row_base_motorisation = mysql_fetch_assoc($base_motorisation);
$totalRows_base_motorisation = mysql_num_rows($base_motorisation);
mysql_select_db($database_bdn, $bdn);
$query_base_marque = "SELECT * FROM marque ORDER BY marque ASC";
$base_marque = mysql_query($query_base_marque, $bdn) or die(mysql_error());
$row_base_marque = mysql_fetch_assoc($base_marque);
$totalRows_base_marque = mysql_num_rows($base_marque);
$clause_where = '';
$is_where = 0;
// motorisation
if( isset($_POST['type_motorisation']) && $_POST['type_motorisation']!='' && $_POST['type_motorisation']!='tous_moteurs' ) {
$clause_where .= ($is_where == 0)? " WHERE " : " AND ";
$clause_where .= " type_motorisation = '".mysql_real_escape_string($_POST['type_motorisation'])."' ";
$is_where = 1;
}
// marque
if( isset($_POST['marque']) && $_POST['marque']!='' && $_POST['marque']!='toutes_marques' ) {
$clause_where .= ($is_where == 0)? " WHERE " : " AND ";
$clause_where .= " marque = '".mysql_real_escape_string($_POST['marque'])."' ";
$is_where = 1;
}
// prix
if( isset($_POST['prix']) && $_POST['prix']!='' && $_POST['prix']!='tous_tarif' ) {
$clause_where .= ($is_where == 0)? " WHERE " : " AND ";
$clause_where .= " prix = '".mysql_real_escape_string($_POST['prix'])."' ";
$is_where = 1;
}
// requete
mysql_select_db($database_bdn, $bdn);
$query_resultat_voiture = "SELECT * FROM voiture ".$clause_where.";";
$resultat_voiture = mysql_query($query_resultat_voiture, $bdn) or die(mysql_error());
$row_resultat_voiture = mysql_fetch_assoc($resultat_voiture);
$totalRows_resultat_voiture = mysql_num_rows($resultat_voiture);
// ...
$editFormAction = $_SERVER['PHP_SELF'];
?>
<h2><img src="images/citroen_titre_droit.png" width="18" height="17" hspace="5" border="0" align="absmiddle" />Nos véhicules</h2>
<br />
<form id="form1" name="form1" method="post" action="v2.php">
<p>
<select name="type_motorisation" size="1" class="form_page" id="type_motorisation">
<option value="">Choisissez la motorisation</option>
<option value="tous_moteurs">toutes les motorisations</option>
<?php
do {
?>
<option value="<?php echo $row_base_motorisation['type_moteur']?>"><?php echo $row_base_motorisation['type_moteur']?></option>
<?php
} while ($row_base_motorisation = mysql_fetch_assoc($base_motorisation));
$rows = mysql_num_rows($base_motorisation);
if($rows > 0) {
mysql_data_seek($base_motorisation, 0);
$row_base_motorisation = mysql_fetch_assoc($base_motorisation);
}
?>
</select>
<br />
<br />
<select name="marque" size="1" class="form_page" id="marque">
<option value="">Choisissez la marque</option>
<option value="toutes_marques">Toutes marques</option>
<?php
do {
?>
<option value="<?php echo $row_base_marque['marque']?>"><?php echo $row_base_marque['marque']?></option>
<?php
} while ($row_base_marque = mysql_fetch_assoc($base_marque));
$rows = mysql_num_rows($base_marque);
if($rows > 0) {
mysql_data_seek($base_marque, 0);
$row_base_marque = mysql_fetch_assoc($base_marque);
}
?>
</select>
<br />
<br />
<select name="prix" size="1" class="form_page" id="prix">
<option selected="selected">Choisissez le prix</option>
<option value="tous_tarif">Tous les prix</option>
<option value="t1">≤ 10 000 </option>
<option value="t2">10 000 - 15 000 </option>
<option value="t3">> 15 000 </option>
</select>
</p>
<p align="right">
<input name="Voir les offres" type="submit" class="bouton" value="Voir les offres" />
</p>
</form>
<p><br />
</p>
<?php do { ?>
<div>
<p><?php echo $row_resultat_voiture['marque']; ?></p>
<p><?php echo $row_resultat_voiture['modele']; ?></p>
<p><?php echo $row_resultat_voiture['motorisation']; ?></p>
<p><?php echo $row_resultat_voiture['photo']; ?></p>
------------------------------------------------------------------ </div>
<?php } while ($row_resultat_voiture = mysql_fetch_assoc($resultat_voiture)); ?>
<?php
mysql_free_result($base_motorisation);
mysql_free_result($base_marque);
mysql_free_result($resultat_voiture);
?> |
Partager