Modifier les prix dans toute la table par multiplication

This commit is contained in:
adebbagh 2009-08-11 08:21:19 +00:00
parent f7abae413a
commit e9876bb653

View File

@ -18,14 +18,15 @@ switch ($view) {
if (sizeof($_POST) > 0) {
$frm = $_POST;
$frm['immediate'] = str_replace(',', '.', $frm['immediate']);
$frm['normal'] = str_replace(',', '.', $frm['normal']);
$frm['superflash'] = str_replace(',', '.', $frm['superflash']);
if(is_numeric($frm['immediate']) || is_numeric($frm['normal']) || is_numeric($frm['superflash'])) {
multiplier($frm);
}
//insere_pays($frm);
//header("Location:".$_SERVER['HTTP_REFERER']);
if(is_numeric($frm['immediate']) || is_numeric($frm['normal']) || is_numeric($frm['superflash'])) {
multiplier($frm);
header("Location:".$_SERVER['HTTP_REFERER']);
}
}
break;
}
@ -40,21 +41,52 @@ function multiplier($frm) {
* Les champs sont dans la variable $frm
*
*/
$immediate = intval($frm['immediate']);
$normal = intval($frm['normal']);
$superflash = intval($frm['superflash']);
$immediate = is_numeric($frm['immediate']) ? $frm['immediate'] : "";
$normal = is_numeric($frm['normal']) ? $frm['normal'] : "";
$superflash = is_numeric($frm['superflash']) ? $frm['superflash'] : "";
include("../mysql_inc.php");
$sql = "SELECT immediate, normal, superflash FROM price";
$sql = "SELECT id, immediate, normal, superflash FROM price";
$result = mysql_query($sql) or die("Une erreur de connexion à la base s'est produite " . __LINE__ . ".<p></p>" . mysql_error());
while($col = mysql_fetc) {
}
while($col = mysql_fetch_array($result, MYSQL_ASSOC)) {
if (!is_numeric($immediate) or !is_numeric($col['immediate'])) {
$result_immediate = $col['immediate'];
}
else {
$result_immediate = ($immediate * $col['immediate']);
}
if (!is_numeric($normal) or !is_numeric($col['normal'])) {
$result_normal = $col['normal'];
}
else {
$result_normal = ($normal * $col['normal']);
}
if (!is_numeric($superflash) or !is_numeric($col['superflash'])) {
$result_superflash = $col['superflash'];
}
else {
$result_superflash = ($superflash * $col['superflash']);
}
$sql = "UPDATE price
SET
immediate = '$result_immediate'
, normal = '$result_normal'
, superflash = '$result_superflash'
WHERE id = '".$col['id']."'
";
mysql_query($sql);
}
mysql_free_result($result);
mysql_close($connexion);
}