2016-04-27 61 views
0

我怎樣才能改變像一個單詞的最後一個字母:最後一個字母改變

您還剩下10周,以及我想基於數字incrase改變周復一週,如果是1,我想是:一週< - 如果2,要2周< - 回聲結果

我有這樣的過程:

function get_weeks_remaining($date, $expire){ 

     $difference = strtotime($expire) - strtotime($date); 
     return floor($difference/604800); 

} 
$link = mysqli_connect("localhost", "user", "pass", "table"); 
$nume = $user->data->username; 
$id = $user->data->id; 
$date = date('m/d/Y h:i:s a', time()); 
$expire_date = 'May 07, 2016'; 
$remain = get_weeks_remaining($date, $expire_date); 

$sql = "SELECT `id`,`remain` FROM `week`"; 
if($result = mysqli_query($link, $sql)){ 
if(mysqli_num_rows($result) > 0){ 
while(list($id,$remain) = mysqli_fetch_array($result)){ 
echo "you have $remain weeks left"; 
} 
mysqli_free_result($result); 
    } 
} 

回答

0
while(list($id,$remain) = mysqli_fetch_array($result)){ 
if($remain > 0 and $remain < 2){ 
    echo "you have $remain week left"; 
}else{ 
    echo "you have $remain weeks left"; 
} 
} 

或只是做echo "you have $remain week/s left";
我希望這會幫助你

+0

它的工作,感謝兄弟! – Fido

+0

如果您的問題已關閉,請接受此答案。謝謝。 – Spiderman

+0

我必須等一些時間才能接受。現在完成,再次感謝! – Fido

相關問題