Page is a not externally linkable
- Code, Content, and Presentation
-- PHP Server Side Scripting
---- Php array help


whitecoder - 10:55 pm on Oct 13, 2012 (gmt 0)


Ok I need some help guys. I need to take an array from an html form into php, and then have it inserted in mysql. I am successfully getting the array from the form to the php part, but I am failing at inserting it into mysql. I will put an example of my code below. The form idea below is dynamically generated and there could be 1 entry or 100 entries that could be generated, but it will always get the name="title_1[]" attribute. I need it to insert all the entries that are there into a new database row. I'm not even sure if this is possible but if more clarification is needed just let me know.

The Form Idea:

<form action="index.php" method="post" data-ajax="false">
<div data-role="fieldcontain" style="border:0;">
<fieldset data-role="controlgroup" data-type="horizontal">
<legend>Title 1:</legend>
<input type="radio" name="title_1[]" id="title_1" value="1" />
<label for="title_1">Ok</label>
<input type="radio" name="title_1[]" id="title_2" value="0" />
<label for="title_2">Not Ok</label>
</fieldset>
</div>
</form>


The Php:

$grab_title = $_POST['title_1'];
$arr = array($grab_title);
echo implode(",",$arr);


The Php to MySQL:
I have failed with multiple ideas here any help?


Thread source:: http://www.webmasterworld.com/php/4507837.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com