我正在使用这个 PHP MySQL 从我的数据库中显示一个可排序的列表。
<?php
$query = "SELECT * FROM question_four ORDER BY recordListingID ASC";
$result = mysql_query( $query );
while( $row = mysql_fetch_array( $result, MYSQL_ASSOC ) ) {
?>
<li id="recordsArray_<?php echo $row['recordID']; ?>"><?php echo $row['recordText']; ?></li>
<?php
}
?>
我没有更新同一张表,而是尝试使用以下代码将其插入到新表中:
$action = mysql_real_escape_string($_POST['action']);
$updateRecordsArray = $_POST['recordsArray'];
if ( $action == "updateRecordsListings" ) {
$listingCounter = 1;
foreach ( $updateRecordsArray as $recordIDValue ) {
$query1 = "INSERT into answers_questionfour(id,recordListingID,recordID,recordText) values ('.$user_fbid.','.$listingCounter.', '.$recordIDValue.','.$recordText.')";
mysql_query( $query1 ) or die('Error, insert query failed');
$listingCounter = $listingCounter + 1;
}
}
但是,现在,它只为一个用户插入。当其他用户试图提交他们的排序列表时。它不会添加到表中。你能帮我弄清楚吗?谢谢