我應該做一個「檢查」,應該有(Index,id,....),但索引應該在100之後重置,但是id必須是auto_incremented。 這是我的代碼,我做了什麼。我沒有得到如何重置索引到0.我甚至不能顯示索引值,它顯示0每當我添加的東西。如何將索引重置爲0
<?php
$host = "localhost";
$user = "root";
$password = "";
$database = "dbcar";
$number = "";
$state_number = "";
$model = "";
$status = "";
$conditions = "";
$date = "";
$number_index = "1";
$connect = mysqli_connect($host,$user,$password,$database);
echo "<h1>Report Log </h1>";
$sqlget = "SELECT * FROM carserv ORDER BY date DESC LIMIT 1";
$sqldata = mysqli_query($connect,$sqlget) or die("error");
echo "<table>";
echo"<tr>
<th>INDEX</th>
<th>ID</th>
<th>State Number</th>
<th>Model</th>
<th>Status</th>
<th>Condition</th>
<th>Date</th>
</tr>";
while($row = mysqli_fetch_array($sqldata,MYSQLI_ASSOC)){
echo" <tr><td>";
echo $row['number_index'];
echo" </td><td>";
echo $row['number'];
echo" </td><td>";
echo $row['state_number'];
echo" </td><td>";
echo $row['model'];
echo" </td><td>";
echo $row['status'];
echo" </td><td>";
echo $row['conditions'];
echo" </td><td>";
echo $row['date'];
echo" </td></tr>";
}
echo "</table>";
function getPosts(){
$posts = array();
$posts[0] = $_POST['state_number'];
$posts[1] = $_POST['number'];
$posts[2] = $_POST['model'];
$posts[3] = $_POST['status'];
$posts[4] = $_POST['conditions'];
$posts[6] = $_POST['number_index'];
return $posts;
}
?>
,這裏是我的輸出:http://imgur.com/GOuCcBU
'SELECT'不更改數據庫,'INSERT /更新'做。很難說你的真實代碼是什麼。 –
另外,'INDEX'是一個MySQL保留字https://dev.mysql.com/doc/refman/5.7/en/keywords.html - 查看你的截圖。 –
我可以告訴你我的整個代碼,如果你想 – deluxion