Note that there are some explanatory texts on larger screens.

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

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload