MySQL数据库中的重复行

时间:2015-07-15 15:37:00

标签: php mysql mysqli

出于某种原因,我的代码每隔一段时间就会将数据输入数据库两次。我已经改变了我的代码并进行了一些调整,但没有运气。我知道我一定是在寻找一些我不知道的东西。

function testfunction() {
    if (array[Series1] !== 'undefined' && array[Series1] !== null) {
        alert("There is data");
    } else {
        alert("No data here");
    }
};

$(document).ready(testfunction);

这是html论坛页面。

<?php
$con = new mysqli("localhost", "******", "******", "******");
if (mysqli_connect_errno()) {
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

$conpo = new mysqli("localhost", "******", "******", "******");
if (mysqli_connect_errno()) {
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

$resultpo = mysqli_query($conpo, "SELECT * FROM fpo ORDER BY ponum DESC LIMIT 1");

while ($rowp = mysqli_fetch_array($resultpo)) {
    $po = $rowp['ponum'];
    $ponum = ++$po;
}

$date = $_POST['date'];
$to = $_POST['to'];
$time = $_POST['time'];
$vin = $_POST['stk_vin'];
$reason = $_POST['reason'];
$amount = $_POST['amount'];
$empnum = $_POST['emp'];
$mananger = $_POST['mananger'];
$accnum = $_POST['acc'];
$store_location = $_POST['store'];
$borr = $_POST['borrowed'];
$oldid = $_POST['oldid'];

mysqli_query($con,
    "INSERT INTO fpo (" .
    "`ponum`, `date`, `to`, `time`, `vin`, `reason`, `amount`, `empnum`, `mananger`, `accnum`, `store_location`, `borr`" .
    ") VALUES (" .
    "'$ponum', '$date', '$to', '$time', '$vin', '$reason', '$amount', '$empnum', '$mananger', '$accnum', '$store_location', '$borr'" .
    ")");
?>

0 个答案:

没有答案