Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to update unlimited form field form in database?
    primarykey
    data
    text
    <p>My form structure is like this in which <code>fields[]</code> input can be added any number of times at time of submission of form.Here i am storing website link in <code>fields[]</code> .</p> <pre><code>&lt;input id="name" name="name" type="text" /&gt; &lt;input id="field_1" name="fields[]" type="text" /&gt; &lt;input id="field_2" name="fields[]" type="text" /&gt; &lt;input id="field_3" name="fields[]" type="text" /&gt; </code></pre> <p>I have managed to store this data in a MySQL database using the table structure below to allow a user to be associated with an unlimited number of websites:</p> <pre><code>Users User_website_link Websites ------ ----------------- --------- Pk:UserID Pk:ID Pk:WebsiteId name UserID Url WebsiteID </code></pre> <p>Let say user fills following data in form {"Jon", "example.com", "example1.com", "example2.com" }</p> <p>So after submitting form table would be looking like this:</p> <p><strong>User table:</strong></p> <pre><code>UserID Username 1 Jon </code></pre> <p><strong>Websites Table:</strong></p> <pre><code>WebsiteID Url 1 example.com 2 example1.com 3 example3.com </code></pre> <p><strong>User_website_link Table:</strong></p> <pre><code>ID UserID WebsiteId 1 1 1 2 1 2 3 1 3 </code></pre> <p>How should I allow the user to edit their URLs after submitting them?</p> <p>So my question is: a user called John wants to delete <code>example3.com</code> and edit <code>example.com</code> to <code>demo.com</code>, So I want to know how to delete some websites from the database and edit some.</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.
 

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