Hi all,
I would like to know how to assign and get the form value when I using it in a loop. I cannot get all the input that I inserted in 'Desc' part and it is from this site. May I know to get this work when I do a loop? Thanks.

a.php

// this can work
<font size="2">Title:</font><br><input type="text" name="Title[]" size="40" value="<?php echo htmlentities($match[$counter], ENT_QUOTES); ?>">
</tr>
<tr>&nbsp;</tr>
// but this can only get the last input when do multiple post
<tr>
    <font size="2">Description:</font>
    <script language="JavaScript" type="text/javascript">
    <!--
    function submitForm() {
    updateRTE('Desc');
    return true;
    }
    
    initRTE("images/", "", "");
    writeRichText('Desc', '', 350, 200, true, false);
    
    //-->
    </script>
</tr>

b.php

$title= $_POST['Title'][$counter];
$desc= $_POST['Desc'][$counter];
mysql_query("insert into post(title, description)values ('$title[$counter]', '$desc[$counter]')")or die (mysql_error());

does any know how to solve this? thanks in advance. I just can't get all the values that I inserted in the 'Desc' part, but for the 'Title[]' part I can. The site that I refer to is in the 1st post.

Try the following code;

$title= $_POST['Title'];
$desc= $_POST['Desc'];
mysql_query("insert into post(title, description)values ('$title[$counter]', '$desc[$counter]')")or die (mysql_error());

if i'm not wrong, you can't transfer $_post array values directly to a variable, you have to assign all the array to a variable and then process on that assigned variable.

this example,i think, would complete my answer above

foreach ( $_POST as $varname => $postitem ) {
echo '<input type="hidden" name="page1_'
.$varname.'" value="'.$postitem.'">';
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.