Problem with making array of text-boxes

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
shajiuddin
Forum Newbie
Posts: 1
Joined: Wed Apr 07, 2010 2:02 am

Problem with making array of text-boxes

Post by shajiuddin »

Hello guys, Please help me...

I am facing a problem while making array of 5 text-boxes of 4 specific products and also problem with save them to mysql (data inserted but not all)... here is html code

Product 1
<input name="demProDesc[]" id="demProDesc[]" type="text" size="15" />
<input name="pufsampling[]" id="pufsampling[]" type="text" size="15" />
<input name="openStock[]" id="openStock[]" type="text" size="15" />
<input name="closeStock[]" id="closeStock[]" type="text" size="15" />
<input name="sold[]" id="sold[]" type="text" size="15" />

Product 2
<input name="demProDesc[]" id="demProDesc[]" type="text" size="15" />
<input name="pufsampling[]" id="pufsampling[]" type="text" size="15" />
<input name="openStock[]" id="openStock[]" type="text" size="15" />
<input name="closeStock[]" id="closeStock[]" type="text" size="15" />
<input name="sold[]" id="sold[]" type="text" size="15" />

Product 3
<input name="demProDesc[]" id="demProDesc[]" type="text" size="15" />
<input name="pufsampling[]" id="pufsampling[]" type="text" size="15" />
<input name="openStock[]" id="openStock[]" type="text" size="15" />
<input name="closeStock[]" id="closeStock[]" type="text" size="15" />
<input name="sold[]" id="sold[]" type="text" size="15" />

Product 4
<input name="demProDesc[]" id="demProDesc[]" type="text" size="15" />
<input name="pufsampling[]" id="pufsampling[]" type="text" size="15" />
<input name="openStock[]" id="openStock[]" type="text" size="15" />
<input name="closeStock[]" id="closeStock[]" type="text" size="15" />
<input name="sold[]" id="sold[]" type="text" size="15" />

php code...

foreach ($_POST['demProDesc'] as $value1)
{
}
foreach ($_POST['pufsampling'] as $value2)
{
}
foreach ($_POST['openStock'] as $value3)
{
}
foreach ($_POST['closeStock'] as $value4)
{
}
foreach ($_POST['sold'] as $value5)
{
}

$sql2="insert into demo_products set demoID='$demoID', demProDesc='$value1', pufsampling='$value2', openStock='$value3', closeStock='$value4', sold='$value5' ";
mysql_query ($sql2);
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Problem with making array of text-boxes

Post by pickle »

[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:1. Select the correct board for your query. Take some time to read the guidelines in the sticky topic.
Moved.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply