php - Add array with unknown size into database -
i need build page user can enter name of categories of products of webstore. created page dynamic input fields user able add categories (which don't know ammount). have name of categories , put database. got script online , made few changes dont know how proceed further on. need php script, how array , insert database.
this form script:
<form method="post" action="setup3.php"> <div class="input_fields_wrap"> <button class="add_field_button">add more fields</button> <div> <input type="text" name="mytext[]"> </div> </div> <div> <input type="submit" value="next" /> </div> </form>
i think point in right direction:
<?php if (! empty($_post['mytext'])) { foreach ($_post['mytext'] $entry) { // perform insert here. } }
i recommend using orm doctrine (http://www.doctrine-project.org/) since tackles lot of security issues you.
if wish stay pretty close low-level database interactions, writing plain sql queries, i'd recommend using pdo (http://php.net/manual/en/book.pdo.php)
Comments
Post a Comment