为每个循环显示多个sql结果,并使用提交按钮单独更新它们 [英] Displaying multiple sql results with for each loop and update them separately with a submit button
本文介绍了为每个循环显示多个sql结果,并使用提交按钮单独更新它们的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用此代码在表中显示多个sql行。我希望每次单击右侧的提交按钮运行sql查询以更新列表中的值,其中用户id等于每行的相应用户ID。我有点困惑如何做任何帮助?
Hi, I am using this code to display multiple sql rows in a table. I want everytime i click the submit button on the right to run an sql query to update a value in the listings table where the user id is equal to the corresponding user id of each row. I am a bit confused on how to do it any help?
<?php
foreach($user_listings as $user_listing){
echo '<tr class="danger">';
echo '<td>'.$user_listing['user_id']. '</td>';
echo '<td>Pending Approval</td>';
echo '<td>'. $user_listing['listing_header']. '</td>';
echo '<td>'. $user_listing['listing_subheader']. '</td>';
echo '<td>'. $user_listing['category']. '</td>';
echo '<td>'. $user_listing['listing_city']. '</td>';
echo '<td>'. $user_listing['listing_adress']. '</td>';
echo '<td>'. $user_listing['listing_text']. '</td>';
echo '<td>';
?>
<form action='' method='POST' class="approve-form">
<input type='submit' value="Approve" class="btn btn-success" name='submit' />
</form>
<?php echo '</td>';
echo '</tr>';
}
?>
</tbody>
推荐答案
user_listings as
user_listings as
user_listing){
echo' < tr class =danger>';
echo'< td>'。
user_listing){ echo '<tr class="danger">'; echo '<td>'.
user_listing ['user_id']。 '< / TD>';
echo'< td>待批准< / td>';
echo'< td>'。
user_listing['user_id']. '</td>'; echo '<td>Pending Approval</td>'; echo '<td>'.
这篇关于为每个循环显示多个sql结果,并使用提交按钮单独更新它们的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文