Please note you have a duplicate conditional there, using '
unkn'.
How about something like this to simplify using a
switch() statement, since you are only changing a single element in the SQL statement:
(untested, ymmv)
Code: Select all
$type = $row_Recordset3['ptype'];
mysql_select_db($database_pickageek, $pickageek);
$query3= 'UPDATE `awpr` SET `pricemin` = ';
switch($type) {
case 'unkn':
$query3.= 1;
break;
case 'smlb':
$query3.= 100;
break;
case 'medb':
$query3.= 500;
break;
case 'bigb':
$query3.= 1000;
break;
default:
$query3.= 1;
}
$query3.= " WHERE `session` = '{$sess}'";
mysql_query($query3) or die(mysql_error());
You don't have to type the query out over and over, and if there is a new type, just add it to the switch() flow control.
You might also have a simple array and use
foreach() to find the right value, e.g.
(untested, ymmv)
Code: Select all
$type_array= array('unkn' => 1, 'smlb' =>100, 'medb' =>500, 'bigb' => 1000);
foreach ($type_array AS $key => $value) {
if ( $row_Recordset3['ptype'] == $key ) {
$pricemin= $type_array[$key];
break;
}else{
$pricemin= 1;
}
}
$query3= sprintf("UPDATE `awpr` SET `pricemin = '%d' WHERE `session`= '%s'", $pricemin, $sess);
Just a couple of different methods, I always try to get away from using big conditionals and writing the same code construct over wherever possible.