MySQL在一个查询中更新整个表

时间:2013-02-12 14:08:06

标签: php mysql database phpmyadmin insert-update

我正在尝试加载和更新整个表的内容。我没有加载数据的问题,但它不会更新..有人可以告诉我这里我做错了什么:

while($show_table   = mysql_fetch_array($result_table)){
    echo "<tr><td><input type='text' name='table_id' value='" . 
        $show_table["id"] . "'/><input type='text' name='table_date' value='" . $show_table["date"] . "'/>
        </td><td>&euro; <input type='text' name='table_week' value='" . $show_table["week"] . "'/>
        </td><td>&euro; <input type='text' name='table_midweek' value='" . $show_table["midweek"] . "'/>
        </td><td>&euro; <input type='text' name='table_weekend' value='" . $show_table["weekend"] . "'/>
        </td><td><input type='text' name='table_type' value='" . $show_table["type"] . "'/>
        </td><td><input type='text' name='table_information' value='" . $show_table["information"] . "'/></td></tr>";
}

echo "</table>
<p><input type='submit' id='form_submit' name='update_confirm' value='Tarieven bijwerken'></p>
</form>";

if ($_POST['update_confirm'] == 'Tarieven bijwerken') {
    $id = $_POST['table_id'];
    $date = $_POST['table_date'];
    $week = $_POST['table_week'];
    $midweek = $_POST['table_midweek'];
    $weekend = $_POST['table_weekend'];
    $type = $_POST['table_type'];
    $information = $_POST['table_information'];

    $update_table = "UPDATE tarieven SET date='$date', week='$week', midweek='$midweek', weekend='$weekend', type='$type', information='$information' WHERE id='$id';";
    $confirm_table  = mysql_query($update_table);

} else {
}

1 个答案:

答案 0 :(得分:0)

您的查询仅更新UPDATE tarieven SET ... WHERE id='$id'指定的1行 - 虽然您循环遍历所有记录并显示它们,但更新不在循环中。

相关问题