Update mysql with $_POST data from while loop
I'm trying to get this round my head, but i am failing quite hard :[
I have 3 rows in a database which i am echoing out in a while() loop.
A user can change search_terms
and then save the fields in mysql, however i don't quite know how to do this, as there are 3 rows, so i can't just do;
<?php
if($_POST['update']) {
mysql_query("....");
}
?>
Here is my code;
<?php
$box_query = mysql_query("SELECT * FROM `ta_boxs`");
while($box = mysql_fetch_array($box_query)) {
echo '<div class="box_content">';
echo '<div class="box">'."\n";
echo '<span class="box_top"></span>';
echo '<div class="box_header"><input type="text" id="title" name="title" class="title-input" value="'.$box['title'].'" /></div>';
echo '<span class="sept"></span>';
echo '<div class="admin-back">';
echo '<form id="form-'.$box['id'].'" name="form-'.$box['id'].'" method="post" action="">';
echo '<p class="sub"><span>Includes:</span> Search for these terms in Twitter Feeds.</p>';
echo '<p class="sub-small">Please enter one word per field or click "add word".</p>';
echo '<p><input type="text" id="search_term_1" name="search_term_1" value="'.$box['search_term_1'].'" class="term-input" />';
echo '<p><input type="text" id="search_term_2" name="search_term_2" value="'.$box['search_term_2'].'" class="term-input" />';
echo '<p><input type="text" id="search_term_3" name="search_term_3" value="'.$box['search_term_3'].'" class="term-input" />';
echo '<span class="hr"></span>';
echo '<p class="sub"><span>Excludes:</span> Ignore these terms in Twitter Feeds.</p>';
echo '<p class="sub-small">Please enter one word per field or click "add word".</p>';
echo '<p><input type="text" id="search_term_1" name="search_term_1" value="'.$box['exc_search_term_1'].'" class="term-input" />';
echo '<p><input type="text" id="search_term_2" name="search_term_2" value="'.$box['exc_search_term_2'].'" class="term-input" />';
echo '<p><input type="text" id="search_term_3" name="search_term_3" value="'.$box['exc_search_term_3'].'" class="term-input" />';
echo '<input type="hidden" id="update" name="update" value="yes" />'
echo '<p><input type="submit" id="update_'.$box['id'].'" name="update_'.$box['id'].'" value="Update" /></p>';
echo '</form>';
echo '</div>';
echo '</div>'."\n";
echo '<span class="box_bottom"></span>';
echo '</div>';
}
?>
There could be 1 output, or 100, but i need a way to save them all, onsubmit. Any ideas?