You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.3 KiB
61 lines
1.3 KiB
<?php
|
|
ini_set('display_errors', 'on');
|
|
|
|
include "fun_global.php";
|
|
include "database.php";
|
|
|
|
// account table
|
|
$accounttype = "A";
|
|
$accountid = "";
|
|
$pwd = "123";
|
|
$name = "";
|
|
$creater = "";
|
|
$create_at = date("Y-m-d H:i:s");
|
|
|
|
// 檢查 accountid 是否未重複並寫入 account 資料表
|
|
$sql = "
|
|
SELECT DISTINCT
|
|
a.accountid,
|
|
w.contractno,
|
|
w.custom
|
|
FROM wipwholestatus AS w
|
|
LEFT JOIN (
|
|
SELECT
|
|
accountid
|
|
FROM account
|
|
) AS a
|
|
ON a.accountid = w.contractno
|
|
WHERE a.accountid IS NULL
|
|
";
|
|
$data = mysqli_query($link, $sql);
|
|
|
|
$J = 0;
|
|
foreach ($data as $key => $row) :
|
|
echo $row['accountid']."<br>";
|
|
echo $J++;
|
|
if (empty($row['accountid'])) {
|
|
|
|
$accountid = $row['contractno'];
|
|
$name = $row['custom'];
|
|
echo $sql2 = "
|
|
INSERT INTO account (
|
|
accounttype,
|
|
accountid,
|
|
pwd,
|
|
name,
|
|
creater,
|
|
create_at
|
|
) VALUES (
|
|
'$accounttype',
|
|
'$accountid',
|
|
'$pwd',
|
|
'$name',
|
|
'$creater',
|
|
'$create_at'
|
|
)
|
|
";
|
|
echo "<br/>";
|
|
mysqli_query($link, $sql2);
|
|
}
|
|
endforeach;
|
|
|
|
|