1
利率
請任何人都可以幫我解決問題,是新的PHP開發領域如何存儲日常基礎到數據庫
正在開發的投資興趣門戶網站,我越來越問題存放利率每日以進入數據庫,實際的問題是存儲興趣與用戶的詳細信息,我使用cron作業運行功能,每24小時它的工作完美,但當我登錄爲用戶它的存儲該用戶的利率值只,其他用戶不存儲,我想我正在使用會話用戶登錄的詳細信息可能是這個問題,請任何人都可以幫助我存儲每個用戶的興趣值與用戶的詳細信息
session_start();
$_SESSION['sess_user'];
$conn = mysqli_connect("localhost", "root", "", "bitmining");
$investedusername = $_SESSION['sess_user'];
$sql3="SELECT sum(inv_amount) as total FROM buyinvest WHERE invested_username='$investedusername'";
$result = mysqli_query($conn, $sql3);
while($row = mysqli_fetch_assoc($result)){
$investment = $row['total'];
$days = 1;
$interest_rate = (350/100/365) * $days ;
$finalvalue = $interest_rate * $days;
}
$date = "SELECT invest_timestamp FROM buyinvest ORDER BY invest_timestamp DESC LIMIT 1";
$result = mysqli_query($conn, $date);
$d_test = mysqli_fetch_assoc($result);
$d_test2 = $d_test["invest_timestamp"];
$timestamp = time();
$investeduser = $_SESSION['sess_user'];
$interestamount = $finalvalue;
$date_interest = date("y-m-d h:i:s");
if ($d_test2 + 86400 == $timestamp){
if ($conn){
$sql3 = "INSERT INTO user_investments(invested_user, interest_amount, date_interest) VALUES('$investeduser','$interestamount','$date_interest')";
if (mysqli_query($conn, $sql3))
{
echo "Updated!";
}
else
{
echo "There is an error.";
}
}
}
else {
echo "Not yet!";
}
請人幫我解決上面的代碼
只有當您希望所有做你只是存儲爲單個用戶數據選擇的所有用戶,並運行上面的代碼在循環中 –
請給我示例代碼 – maffidesigners
只需獲取所有用戶並在循環中運行查詢 –