Try changing your inputs to:
PRINT "<INPUT type='text' name='name_array[$id]' value='$name'>";
PRINT "<INPUT type='text' name='email_array[$id]' value='$email'><BR>";

On the following page after the form is submitted, PHP will create 2 new
arrays, $name_array and $email_array. From there, you can do a foreach on
the arrays:

foreach($name_array as $id => $name)
{
        print "My name is $name and my e-mail is " . $email_array[$id] .
"<BR>";
}

- Jonathan

-----Original Message-----
From: Morgan Tocker [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, June 26, 2001 7:04 PM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Variable Variables in PHP


I am having trouble with variable variables;

I want to create a form as follows :-

<?

$result = mysql_query("SELECT * FROM name_and_email");
$num = mysql_numrows("$result");
if ($num!="0") {
    $i = 0;
    PRINT "<FORM action='test.php'>";
    WHILE ($i < $num) {
        $name = mysql_result($result,$i,name);
        $email = mysql_result($result,$i,email);
        $id = mysql_result($result,$i,id);
        PRINT "<INPUT type='text' name='name$id' value='$name'>";
        PRINT "<INPUT type='text' name='email$id' value='$email'><BR>";
        
        $i++;
    }
    PRINT "<INPUT type='submit'></FORM>";
}

?>


## THIS SHOULD SUBMIT SOMETHING LIKE THIS >>>>

test.php?name1=avalue&email1=avalueagain&name2=secondname&email2=secondemail


THE PROBLEM:
>From PHP with variable variables, how do I change $name1 and $email1 into -

## for all $name.$x values do this......
$sql = "UPDATE name_and_email SET name = '$name1', email = '$email1' WHERE
id = '$id'";


Many thanks if someone can help,
Morgan Tocker.



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to