PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.php > Multiple field Arrays
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Multiple field Arrays

Réponse
 
LinkBack Outils de la discussion
Vieux 04/11/2007, 21h58   #1
Kevin Davis
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Multiple field Arrays

Hello,

I have an quick question.

I have the following form:

<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post" >
<?php linecount = 5 ?>
<?php
for (i=0; i< linecount;i++)
{
<input type="text" name[] value=field1>
<input type="text" name[] value=field2>
<input type="text" name[] value=field3>
<input type="text" name[] value=field4>
<input type="text" name[] value=field5>
<input type="text" name[] value=field6>
}
</form>

Then I try to split up the data:
foreach ($_POST['name'] as $namef)
{
echo $namef."<br/>;

}

Here is the problem. The multiple fields seem not to be splitting up
because the output seems to coming out in a single blob.

What I would like to do is split up the array based upon the field
entry so I can insert the info into the database.

Thank you.

Kevin

  Réponse avec citation
Vieux 04/11/2007, 23h21   #2
Jerry Stuckle
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Multiple field Arrays

Kevin Davis wrote:
> Hello,
>
> I have an quick question.
>
> I have the following form:
>
> <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post" >
> <?php linecount = 5 ?>
> <?php
> for (i=0; i< linecount;i++)
> {
> <input type="text" name[] value=field1>
> <input type="text" name[] value=field2>
> <input type="text" name[] value=field3>
> <input type="text" name[] value=field4>
> <input type="text" name[] value=field5>
> <input type="text" name[] value=field6>
> }
> </form>
>
> Then I try to split up the data:
> foreach ($_POST['name'] as $namef)
> {
> echo $namef."<br/>;
>
> }
>
> Here is the problem. The multiple fields seem not to be splitting up
> because the output seems to coming out in a single blob.
>
> What I would like to do is split up the array based upon the field
> entry so I can insert the info into the database.
>
> Thank you.
>
> Kevin
>
>


foreach ($_POST['name'] as $namef)
{
echo $namef."<br/>";
}

BTW - if you're using html, that should be <br> instead of <br/>.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

  Réponse avec citation
Vieux 04/11/2007, 23h22   #3
Jerry Stuckle
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Multiple field Arrays

Kevin Davis wrote:
> Hello,
>
> I have an quick question.
>
> I have the following form:
>
> <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post" >
> <?php linecount = 5 ?>
> <?php
> for (i=0; i< linecount;i++)
> {
> <input type="text" name[] value=field1>
> <input type="text" name[] value=field2>
> <input type="text" name[] value=field3>
> <input type="text" name[] value=field4>
> <input type="text" name[] value=field5>
> <input type="text" name[] value=field6>
> }
> </form>
>
> Then I try to split up the data:
> foreach ($_POST['name'] as $namef)
> {
> echo $namef."<br/>;
>
> }
>
> Here is the problem. The multiple fields seem not to be splitting up
> because the output seems to coming out in a single blob.
>
> What I would like to do is split up the array based upon the field
> entry so I can insert the info into the database.
>
> Thank you.
>
> Kevin
>
>


Oops, pressed send too quick...

Also, your fields should be:

<input type="text" name="name[]" value=field1>

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

  Réponse avec citation
Vieux 05/11/2007, 02h53   #4
Lars Eighner
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Multiple field Arrays

In our last episode,
<1194213534.765875.294610@d55g2000hsg.googlegroups .com>, the lovely and
talented Kevin Davis broadcast on comp.lang.php:

> Hello,


> I have an quick question.


It is really an HTML question. Look up the input element in
your copy of the spec.

> I have the following form:


><form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post" >
><?php linecount = 5 ?>
><?php
> for (i=0; i< linecount;i++)
> {
><input type="text" name[] value=field1>
><input type="text" name[] value=field2>
><input type="text" name[] value=field3>
><input type="text" name[] value=field4>
><input type="text" name[] value=field5>
><input type="text" name[] value=field6>
> }
></form>


> Then I try to split up the data:
> foreach ($_POST['name'] as $namef)
> {
> echo $namef."<br/>;


> }


> Here is the problem. The multiple fields seem not to be splitting up
> because the output seems to coming out in a single blob.


> What I would like to do is split up the array based upon the field
> entry so I can insert the info into the database.


> Thank you.


> Kevin


--
Lars Eighner <http://larseighner.com/> <http://myspace.com/larseighner>
Countdown: 442 days to go.
What do you do when you're debranded?
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 03h51.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,14005 seconds with 12 queries