Wrox Programmer Forums
|
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 31st, 2005, 12:50 AM
Registered User
 
Join Date: Dec 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to hillbilly geek
Default Array woes

I'm a newbie, working with php4.

I'm passing arrays from a form: a series of variables with the same
name like: Child[] and Age[]

I'm capturing them with:
        $Child[] = array($_POST['Child[]']);
        $Age[] = array($_POST['Age[]']) ;

then, I'm using:

 <?php
$Count=0 ;
echo "<h3>Registering $numChildren Children</h3>" ;
do
{
                echo "<p>$Child[$Count], Age $Age[$Count], $Gender[$Count]<p>" ;
                echo "<p>Info: " . $Info[$Count] . "<p>" ;
                $CheckEmpty = "$Child[$Count]" ;
                $Count="$Count+1" ;

} while ($CheckEmpty!="") ;

if ($Count==1) echo "Not Applicable" ;
?>
However, I get this result on the page: (for 2 entries):

Array, Age Array, Array
Info: Array

, Age ,
Info:

In other words: the first set of values are replaced with "Array"

And the second set of values don't show up.
I also tried it with three sets, and the third set didn't register at all
Help? Thanks!

---
Descartes goes into a restaurant and orders a cup of coffee. He sits for a while, drinking his coffee and reading the paper. A little while later, the waitress comes by and asks him if he would like another cup. He says "I think not" and disappears...
 
Old December 31st, 2005, 03:21 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 357
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anshul
Default

Many times, we need to reset() arrays before using them. I'm though, not sure if it solves your problem ..

`~@#\^%&*/\.<.\/-|+|_!:;..=?>
Students' finances
 
Old January 8th, 2006, 12:28 AM
Friend of Wrox
 
Join Date: Dec 2004
Posts: 154
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm not too sure how you "POST" an array to be honnest??
Its 4am here so i'm going to make an observation cause I don't want to create an array right now ;)
Did you try:
<?php
$Child[]=$_POST['Child[]'];





Similar Threads
Thread Thread Starter Forum Replies Last Post
Installation woes gcallaway Beginning PHP 9 March 31st, 2008 07:05 PM
onClick woes DennyLoi Javascript How-To 1 November 3rd, 2007 01:13 PM
Form woes komputatek Access 2 March 15th, 2005 11:47 AM
Installation woes mattm BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 2 June 26th, 2003 03:40 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.