3 つの列を持つデータベース テーブルを作成する必要があります (この質問の場合)。
必要なテーブルを作成するためのコードを提供します。これをコピーして PHPmyAdmin に貼り付けるだけです。
Create Table donations(
company_id int,
user_id int,
donate_num int,
datetime DATETIME
)
次に、INSERT INTO
関数を使用して、新しい mysqli 関数を使用してデータベースを更新します (サーバー/ユーザー名などをデータベースの詳細に置き換えます)。
$mysqli= new mysqli('SERVER','USERNAME','PASSWORD','DATABASE NAME')
if ($mysqli->connect_error) {
die('Connect Error (' . $mysqli->connect_errno . ') '
. $mysqli->connect_error);
}
function escapeStringSlash($value) {
global $mysqli;
if (get_magic_quotes_gpc()) {
$value = stripslashes($value);
}
if (!is_numeric($value)) {
$value = $mysqli->real_escape_string($value);
}
return $value;
}
$coid=escapeStringSlash($row['companyid']);
$userid = escapeStringSlash($_SESSION['userid']);
$selectbox = escapeStringSlash($_POST['select']);
$date = new DateTime();
$currentTime = $date->format("Y-m-d H:i:s");
if($insertDonations=$mysqli->query("INSERT INTO donations(company_id,user_id,donate_num,datetime) VALUES(".$coid.",".$userid.",".$selectbox.",'".$currentTime."')"){
echo "Number of donations received";
}else{
echo "There was a problem inserting this.";
}
$mysqli->close();