以下代码会在拍卖脚本中将当前价格加1。
我想用简单的表格替换所有相关的东西
如果x是介于100和500之间的任何数字 然后将10添加到x
如果x是501到1000之间的任何数字 然后加20到x
x是指任何一次出价后的当前价格 像这张照片的东西[img] http://www.premiumpress.com/wp-content/uploads/2015/01/increments1.jpg [/ img]
问题在于我不是编码员也不是程序员。 :(
所以任何帮助都会很棒
感谢大家
// BIDDING AND MAKE OFFER
case "newbid": {
if(!is_numeric($_POST['bidamount'])){
// LEAVE MSG
$GLOBALS['error_message'] = str_replace("%a", $_POST['bidamount'] ,$CORE->_e(array('auction','29')));
}else{
//1. GET ANY CURRENT BIDDING DATA
$current_bidding_data = get_post_meta($post->ID,'current_bid_data',true);
if(!is_array($current_bidding_data)){ $current_bidding_data = array(); }
//2. ORDER IT BY KEY (WHICH HOLDS THE BID AMOUNT)
krsort($current_bidding_data);
// 3. SWITCH THE BID TYPE TO PERFORM ACTIONS
switch($_POST['bidtype']){
// BIDDING SYSTEM
case "bid": {
// GET THE CURRENT PRICE
$current_price = get_post_meta($post->ID,'price_current',true);
// CHECK IF THE BID AMOUNT IS GREATER THAN THE EXISTINT CURRENT PRICE
if( $_POST['bidamount'] > $current_price ){
// LETS CHECK IF WE HAVE A BIGGER AMOUNT THAN THE BIDDERS TOTAL
$checkme = current($current_bidding_data);
// OLD BIDDER IS STILL WINNER
if(is_numeric($current_price) && $current_price > 0 && isset($checkme) && ( $checkme['max_amount'] >= $_POST['bidamount']) ){
$is_new_bid = false;
if($_POST['bidamount'] == $checkme['max_amount']){
$current_price = $_POST['bidamount'];
}else{
$current_price = $_POST['bidamount']+1;
}
$GLOBALS['error_message'] = $CORE->_e(array('auction','30'));
// NEW BIDDER IS WINNER
}else{
$is_new_bid = true;
// EMAIL THE OLD BIDDER AND LET THEM KNOW THEY HAVE BEEN OUTBID
if(isset($checkme['userid']) && $checkme['userid'] != $userdata->data->ID){
$_POST['username'] = $checkme['username'];
$_POST['title'] = $post->post_title;
$_POST['link'] = get_permalink($post->ID);
$CORE->SENDEMAIL($checkme['userid'],'auction_outbid');
}
// NOW SET NEW PRICE
if($current_price == "" || $current_price == "0"){
$current_price = 1;
}elseif(isset($checkme['max_amount'])){
$current_price = $checkme['max_amount']+1;
}else{
$current_price++;
}
$GLOBALS['error_message'] = $CORE->_e(array('auction','31'));
}
}
// UPDATE THE LISTING WITH THE NEW CURRENT PRICE
update_post_meta($post->ID,'price_current', $current_price);
} break;
}
//3. ADD ON THE NEW BID
if($is_new_bid){
$current_bidding_data[$_POST['bidamount']] = array( 'max_amount' =>$_POST['bidamount'], 'userid' => $userdata->data->ID, 'username' => $userdata->data->user_nicename, 'date' => current_time( 'mysql' ), 'bid_type' => $_POST['bidtype'] );
//4. MERGE THE TWO AND SAVE
update_post_meta($post->ID,'current_bid_data', $current_bidding_data);
}
//5. ADD LOG ENTRY
$CORE->ADDLOG("<a href='(ulink)'>".$userdata->user_nicename.'</a> bid on the listing <a href="(plink)"><b>['.$post->post_title.']</b></a>.', $userdate->ID, $post->ID ,'label-info');
//6. UPDATE USER META TO INDICATE THEY BID ON THIS ITEM
$user_bidding_data = get_user_meta($userdata->data->ID,'user_bidding_data',true);
if(!is_array($user_bidding_data)){ $user_bidding_data = array(); }
$user_bidding_data[] = array('postid' => $post->ID, 'max_amount' =>$_POST['bidamount'], 'date' => current_time( 'mysql' ), 'bid_type' => $_POST['bidtype'], 'title' => $post->post_title);
update_user_meta($userdata->data->ID,'user_bidding_data',$user_bidding_data);
}
} break;
}// end switch
}// end if
}
答案 0 :(得分:0)
if (x < 100 || x > 1000{//do nothing}
elseif (x < 501){x += 10;}
else{x += 20}