Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to add records to database using a joined table - codeigniter
    text
    copied!<p>I made a form for adding factories to my database. this works great but i can't show my factories on the page because they're in a joined table, but when i submit the page it does not add an id to the joined table so the factory won't be shown at the page.</p> <p>the joined table looks like this:</p> <pre><code>bedrijfcategorieen ------------------ idbedrijfcat idbedrijven idcategorieen </code></pre> <p>Where idbedrijven is the id for my factories table.</p> <p>My controller function for adding factories:</p> <pre><code>function bedrijven() { $data['options'] = $ddmenu; $this-&gt;load-&gt;view('members/header'); $this-&gt;load-&gt;view('members/editform', $data); $this-&gt;load-&gt;view('members/footer'); } function addbedrijven() { $this-&gt;members_model-&gt;addbedrijf(); redirect('members/index'); } </code></pre> <p>my model function for adding factories:</p> <pre><code>function addbedrijf() { $data = array( 'idbedrijven' =&gt; $idbedrijven, 'Bedrijfsnaam' =&gt; $this-&gt;input-&gt;post('Bedrijfsnaam'), 'Postcode' =&gt; $this-&gt;input-&gt;post('Postcode'), 'Plaats' =&gt; $this-&gt;input-&gt;post('Plaats'), 'Telefoonnummer' =&gt; $this-&gt;input-&gt;post('Telefoonnummer'), 'Email' =&gt; $this-&gt;input-&gt;post('Email'), 'Website' =&gt; $this-&gt;input-&gt;post('Website'), 'Profiel' =&gt; $this-&gt;input-&gt;post('Profiel'), 'Adres' =&gt; $this-&gt;input-&gt;post('Adres'), 'logo' =&gt; $this-&gt;input-&gt;post('logo') ); $this-&gt;db-&gt;insert('bedrijven', $data); } </code></pre> <p>i would like to add my factories trough the joined table. so it would be easier to add categories to the factories too.</p> <p>I tried <code>where('bedrijfcategorieen.idbedrijven = idbedrijven</code> but it did not work.</p> <hr> <p><strong>table scheme</strong></p> <pre><code>factories --------- idfactories factoryname adress postcode country telephone ... ... categories ---------- idcategories category factorycategories ----------------- idfactorycat idfactories idcategories </code></pre> <hr>
 

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