<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Getting Multiple Array Form Values With PHP</title>
	<atom:link href="http://www.web-design-talk.co.uk/94/getting-multiple-array-form-values-with-php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.web-design-talk.co.uk/94/getting-multiple-array-form-values-with-php/</link>
	<description>Web Design &#38; Development Blog</description>
	<lastBuildDate>Sat, 04 Feb 2012 19:06:39 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: neo99</title>
		<link>http://www.web-design-talk.co.uk/94/getting-multiple-array-form-values-with-php/comment-page-1/#comment-12646</link>
		<dc:creator>neo99</dc:creator>
		<pubDate>Wed, 19 Oct 2011 06:21:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.web-design-talk.co.uk/?p=94#comment-12646</guid>
		<description>Thank you very much. You know what, your posting really saved me from headache and heartache. I really appreciate what you have posted on your website.

You are awesome man, uber cool! &quot;-)</description>
		<content:encoded><![CDATA[<p>Thank you very much. You know what, your posting really saved me from headache and heartache. I really appreciate what you have posted on your website.</p>
<p>You are awesome man, uber cool! &#8220;-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kema</title>
		<link>http://www.web-design-talk.co.uk/94/getting-multiple-array-form-values-with-php/comment-page-1/#comment-9814</link>
		<dc:creator>kema</dc:creator>
		<pubDate>Thu, 07 Jul 2011 10:15:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.web-design-talk.co.uk/?p=94#comment-9814</guid>
		<description>I like your coding and will like to share some projects with you for your assistant.</description>
		<content:encoded><![CDATA[<p>I like your coding and will like to share some projects with you for your assistant.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: simon</title>
		<link>http://www.web-design-talk.co.uk/94/getting-multiple-array-form-values-with-php/comment-page-1/#comment-4473</link>
		<dc:creator>simon</dc:creator>
		<pubDate>Tue, 14 Dec 2010 13:52:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.web-design-talk.co.uk/?p=94#comment-4473</guid>
		<description>soory again, my last comment woked it out, I had to put the &quot;$inserted_user_id = $db-&gt;last_insert_id();&quot; outside the loop!

cheers</description>
		<content:encoded><![CDATA[<p>soory again, my last comment woked it out, I had to put the &#8220;$inserted_user_id = $db-&gt;last_insert_id();&#8221; outside the loop!</p>
<p>cheers</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: simon</title>
		<link>http://www.web-design-talk.co.uk/94/getting-multiple-array-form-values-with-php/comment-page-1/#comment-4470</link>
		<dc:creator>simon</dc:creator>
		<pubDate>Tue, 14 Dec 2010 13:16:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.web-design-talk.co.uk/?p=94#comment-4470</guid>
		<description>sorry it seems to leave the code out but I have a the  if and for you illustrate above to get the $fields and $fields2 variables

it must have some to do with the last insert id line? I can&#039;T work it out

$inserted_user_id = $db-&gt;last_insert_id();</description>
		<content:encoded><![CDATA[<p>sorry it seems to leave the code out but I have a the  if and for you illustrate above to get the $fields and $fields2 variables</p>
<p>it must have some to do with the last insert id line? I can&#8217;T work it out</p>
<p>$inserted_user_id = $db-&gt;last_insert_id();</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: simon</title>
		<link>http://www.web-design-talk.co.uk/94/getting-multiple-array-form-values-with-php/comment-page-1/#comment-4469</link>
		<dc:creator>simon</dc:creator>
		<pubDate>Tue, 14 Dec 2010 13:10:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.web-design-talk.co.uk/?p=94#comment-4469</guid>
		<description>in the above code 
for ( $i=0;$ilast_insert_id();

should read

for ( $i=0;$ilast_insert_id();</description>
		<content:encoded><![CDATA[<p>in the above code<br />
for ( $i=0;$ilast_insert_id();</p>
<p>should read</p>
<p>for ( $i=0;$ilast_insert_id();</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: simon</title>
		<link>http://www.web-design-talk.co.uk/94/getting-multiple-array-form-values-with-php/comment-page-1/#comment-4468</link>
		<dc:creator>simon</dc:creator>
		<pubDate>Tue, 14 Dec 2010 13:07:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.web-design-talk.co.uk/?p=94#comment-4468</guid>
		<description>HI great tutorial, including the adding unlimited form fileds one.

I have one problem when comes to adding the values to the database. I seem to have got it so USER 1 is entered OK, I also have it so that if I add 3 websites they are all entered as such going thru the for loop.

websiteID             website_url           website_title  
       1                           1                          t1
       2                           2                          t2
       3                           3                          t3

the problem comes when the website ID ar give a user ID, the websites 2 &amp; 3 are given a 0 user ID

here is my code, any help to get the user ID added to the 2 and 3 records woud great
===========
if (isset($_POST[&#039;fields&#039;])) {
	
	for ( $i=0;$ilast_insert_id();

$sql_website = sprintf(&quot;INSERT INTO websites (Website_URL, Website_Title) VALUES (&#039;%s&#039;,&#039;%s&#039;)&quot;,
mysql_real_escape_string($fields),
mysql_real_escape_string($fields2));   
$result_website = $db-&gt;query($sql_website);
$inserted_website_id = $db-&gt;last_insert_id();
			
			
			
//Insert into users_websites_link table
$sql_users_website = sprintf(&quot;INSERT INTO users_websites_link (UserID, WebsiteID) VALUES (&#039;%s&#039;,&#039;%s&#039;)&quot;,
 mysql_real_escape_string($inserted_user_id),
mysql_real_escape_string($inserted_website_id) );  
$result_users_website = $db-&gt;query($sql_users_website);
			
==========</description>
		<content:encoded><![CDATA[<p>HI great tutorial, including the adding unlimited form fileds one.</p>
<p>I have one problem when comes to adding the values to the database. I seem to have got it so USER 1 is entered OK, I also have it so that if I add 3 websites they are all entered as such going thru the for loop.</p>
<p>websiteID             website_url           website_title<br />
       1                           1                          t1<br />
       2                           2                          t2<br />
       3                           3                          t3</p>
<p>the problem comes when the website ID ar give a user ID, the websites 2 &amp; 3 are given a 0 user ID</p>
<p>here is my code, any help to get the user ID added to the 2 and 3 records woud great<br />
===========<br />
if (isset($_POST['fields'])) {</p>
<p>	for ( $i=0;$ilast_insert_id();</p>
<p>$sql_website = sprintf(&#8220;INSERT INTO websites (Website_URL, Website_Title) VALUES (&#8216;%s&#8217;,'%s&#8217;)&#8221;,<br />
mysql_real_escape_string($fields),<br />
mysql_real_escape_string($fields2));<br />
$result_website = $db-&gt;query($sql_website);<br />
$inserted_website_id = $db-&gt;last_insert_id();</p>
<p>//Insert into users_websites_link table<br />
$sql_users_website = sprintf(&#8220;INSERT INTO users_websites_link (UserID, WebsiteID) VALUES (&#8216;%s&#8217;,'%s&#8217;)&#8221;,<br />
 mysql_real_escape_string($inserted_user_id),<br />
mysql_real_escape_string($inserted_website_id) );<br />
$result_users_website = $db-&gt;query($sql_users_website);</p>
<p>==========</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rob</title>
		<link>http://www.web-design-talk.co.uk/94/getting-multiple-array-form-values-with-php/comment-page-1/#comment-4416</link>
		<dc:creator>Rob</dc:creator>
		<pubDate>Sun, 12 Dec 2010 18:44:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.web-design-talk.co.uk/?p=94#comment-4416</guid>
		<description>&lt;a href=&quot;#comment-4220&quot; rel=&quot;nofollow&quot;&gt;@charles &lt;/a&gt; 

You&#039;d simply use thew &#039;files&#039; array, instead of the &#039;post&#039; array. E.g. assuming you&#039;re using a file input called &#039;the_file&#039; and have added enctype=&quot;multipart/form-data&quot; to your form tag, you&#039;d access the file name of a particular file like: 

$file_name = $_FILES[&quot;the_file&quot;][&quot;name&quot;][$i];

hope that helps! :)</description>
		<content:encoded><![CDATA[<p><a href="#comment-4220" rel="nofollow">@charles </a> </p>
<p>You&#8217;d simply use thew &#8216;files&#8217; array, instead of the &#8216;post&#8217; array. E.g. assuming you&#8217;re using a file input called &#8216;the_file&#8217; and have added enctype=&#8221;multipart/form-data&#8221; to your form tag, you&#8217;d access the file name of a particular file like: </p>
<p>$file_name = $_FILES["the_file"]["name"][$i];</p>
<p>hope that helps! <img src='http://www.web-design-talk.co.uk/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: charles</title>
		<link>http://www.web-design-talk.co.uk/94/getting-multiple-array-form-values-with-php/comment-page-1/#comment-4220</link>
		<dc:creator>charles</dc:creator>
		<pubDate>Mon, 06 Dec 2010 10:00:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.web-design-talk.co.uk/?p=94#comment-4220</guid>
		<description>how do you go about it if the one of the elements is file?</description>
		<content:encoded><![CDATA[<p>how do you go about it if the one of the elements is file?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James</title>
		<link>http://www.web-design-talk.co.uk/94/getting-multiple-array-form-values-with-php/comment-page-1/#comment-2087</link>
		<dc:creator>James</dc:creator>
		<pubDate>Thu, 22 Apr 2010 19:06:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.web-design-talk.co.uk/?p=94#comment-2087</guid>
		<description>Thanks for this Rob, working like a gem, however I also have multiple Radio buttons being created and since their name is the same across each addition, you can&#039;t select just one. If that makes sense. Also having trouble with form validation since fields share the same name.

Any tips would be great!

Thank you.</description>
		<content:encoded><![CDATA[<p>Thanks for this Rob, working like a gem, however I also have multiple Radio buttons being created and since their name is the same across each addition, you can&#8217;t select just one. If that makes sense. Also having trouble with form validation since fields share the same name.</p>
<p>Any tips would be great!</p>
<p>Thank you.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rob</title>
		<link>http://www.web-design-talk.co.uk/94/getting-multiple-array-form-values-with-php/comment-page-1/#comment-117</link>
		<dc:creator>Rob</dc:creator>
		<pubDate>Tue, 29 Sep 2009 19:18:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.web-design-talk.co.uk/?p=94#comment-117</guid>
		<description>&lt;a href=&quot;#comment-112&quot; rel=&quot;nofollow&quot;&gt;@dudu &lt;/a&gt;

I&#039;m not exactly sure what you mean? My example is based purely on a HTML form, using PHP to read the results. Using MySQL or SQL doesn&#039;t come into it currently :) 

You could of course use the values within the loop to insert into a MS SQL database (as oppossed to MySQL). E.g. you&#039;d have your insert statement within for loop. More on the latter is in a previous article I wrote, see http://www.web-design-talk.co.uk/58/adding-unlimited-form-fields-with-jquery-mysql/</description>
		<content:encoded><![CDATA[<p><a href="#comment-112" rel="nofollow">@dudu </a></p>
<p>I&#8217;m not exactly sure what you mean? My example is based purely on a HTML form, using PHP to read the results. Using MySQL or SQL doesn&#8217;t come into it currently <img src='http://www.web-design-talk.co.uk/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  </p>
<p>You could of course use the values within the loop to insert into a MS SQL database (as oppossed to MySQL). E.g. you&#8217;d have your insert statement within for loop. More on the latter is in a previous article I wrote, see <a href="http://www.web-design-talk.co.uk/58/adding-unlimited-form-fields-with-jquery-mysql/" rel="nofollow">http://www.web-design-talk.co.uk/58/adding-unlimited-form-fields-with-jquery-mysql/</a></p>
]]></content:encoded>
	</item>
</channel>
</rss>

