Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I get this code to enter multiple values back into the database
    primarykey
    data
    text
    <p>I have been fiddling around with this code for a while and I cannot get it to work! I am a bit of a noob with this type of coding so please bare that in mind if/when I ask any "stupid questions".</p> <p>Basically I would like user to be able to select more than one option from a list generated from the db and feed that back in as their selection. At the moment it is a multiple select box but it only enters one value back into the db.</p> <p>Any help will be greatly appreciated. Thanks </p> <pre><code>function ProjectTheme_get_categories($taxo, $selected = "", $include_empty_option = "", $ccc = "") { $args = "orderby=name&amp;order=ASC&amp;hide_empty=0&amp;parent=0"; $terms = get_terms( $taxo, $args ); $ret = '&lt;select multiple size="20" name="'.$taxo.'_cat" class="'.$ccc.'" id="scrollselect '.$ccc.'"&gt;'; if(!empty($include_empty_option)) $ret .= "&lt;option value=''&gt;".$include_empty_option."&lt;/option&gt;"; if(empty($selected)) $selected = -1; foreach ( $terms as $term ) { $id = $term-&gt;term_id; $ret .= '&lt;option '.($selected == $id ? "selected='selected'" : " " ).' value="'.$id.'"&gt;'.$term-&gt;name.'&lt;/option&gt;'; $args = "orderby=name&amp;order=ASC&amp;hide_empty=0&amp;parent=".$id; $sub_terms = get_terms( $taxo, $args ); foreach ( $sub_terms as $sub_term ) { $sub_id = $sub_term-&gt;term_id; $ret .= '&lt;option '.($selected == $sub_id ? "selected='selected'" : " " ).' value="'.$sub_id.'"&gt;&amp;nbsp; &amp;nbsp;|&amp;nbsp; '.$sub_term-&gt;name.'&lt;/option&gt;'; $args2 = "orderby=name&amp;order=ASC&amp;hide_empty=0&amp;parent=".$sub_id; $sub_terms2 = get_terms( $taxo, $args2 ); foreach ( $sub_terms2 as $sub_term2 ) { $sub_id2 = $sub_term2-&gt;term_id; $ret .= '&lt;option '.($selected == $sub_id2 ? "selected='selected'" : " " ).' value="'.$sub_id2.'"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&amp;nbsp; '.$sub_term2-&gt;name.'&lt;/option&gt;'; } } } $ret .= '&lt;/select&gt;'; return $ret; } </code></pre> <p>Just in case I was not very clear my question is:</p> <p>How do I get the code above to enter multiple values back into the database?</p>
    singulars
    1. This table or related slice is empty.
    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.
    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