Current location: Hot Scripts Forums » Programming Languages » PHP » help with arrays in form


help with arrays in form

Reply
  #1 (permalink)  
Old 07-18-05, 04:34 PM
mariuso mariuso is offline
New Member
 
Join Date: Dec 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
help with arrays in form

I'm making a little script that will help me when I shall start programming the vote for my new page.

But it dosent take the data in the form and put it in the array.

The script:
PHP Code:

<?php

    
if($test==test) {
        for(
$i=1$i<=7$i++) {
            
$dato $_POST["dato"];
            
$v1 $dato[$i][0];
            
$v2 $dato[$i][1];
            echo(
"<p>".$i." Verdi 1: ".$v1."");
            echo(
"Verdi 2: ".$v2."</p>");
        } 
    }
    else{
        echo(
'<form action="t1.php?test=test" enctype="text/plain" method="post">');
        for(
$i=1$i<=7$i++) {
            echo 
''.$i.' <input type="text" name="dato[$i][]" value="test'.$i.'"/>';
            echo 
'<input type="text" name="dato[$i][]" value="test'.$i.'"/>';
            echo 
'<br />';
        } 
        echo(
'<input type="submit" value="test">
        </form>'
);
    }
?>
it can be tested here: http://hygge.gamebase.no/t1.php
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 07-18-05, 07:34 PM
the_mole001's Avatar
the_mole001 the_mole001 is offline
Newbie Coder
 
Join Date: Feb 2004
Location: Australia
Posts: 96
Thanks: 0
Thanked 0 Times in 0 Posts
Perhaps your code should look a little bit more like:

PHP Code:

<?php 

    
if(isset($_GET['submit'])) { 
        for(
$i=1$i<=7$i++) { 
            
$dato $_POST["dato"]; 
            
$v1 $dato[$i][0]; 
            
$v2 $dato[$i][1]; 
            echo(
"<p>".$i." Verdi 1: ".$v1.""); 
            echo(
"Verdi 2: ".$v2."</p>"); 
        } 
    } 
    else{ 
        echo(
'<form action="t1.php?test=test" enctype="text/plain" method="post">'); 
        for(
$i=1$i<=7$i++) { 
            echo 
''.$i.' <input type="text" name="dato[$i][]" value="test'.$i.'"/>'
            echo 
'<input type="text" name="dato[$i][]" value="test'.$i.'"/>'
            echo 
'<br />'
        } 
        echo(
'<input type="submit" value="test" name='submit'> 
        </form>'
); 
    } 
?>
I just changed the method it uses for checking if the person has filled in the form yet or not, hope it helps.
__________________
Current Project: GGAC Website
Project Link: http://peter.5gigs.com/
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
checkCheckboxGroup broken after form consolidation ski_woman JavaScript 0 01-12-05 12:00 PM
Arrays and Clientside Form Collection helorf JavaScript 1 01-08-05 11:10 AM
Form Validation with Arrays blessedrub JavaScript 1 12-07-04 03:18 AM
formmail problem gscraper Perl 12 08-27-04 04:06 AM
Limit the form submission according to time bionicsamir PHP 7 05-10-04 12:10 AM


All times are GMT -5. The time now is 08:35 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.