为每个循环显示多个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']。 '&LT; / TD&GT;';
echo'< td>待批准< / td>';
echo'< td>'。
user_listing['user_id']. '</td>'; echo '<td>Pending Approval</td>'; echo '<td>'.