Retaining values in input fields

Hello,

I have a table where rows, columns and input fields within the cells are dynamically generated as in


<?php 
					   			
						for($i=0; $i<3; $i++) {
							echo("<tr>");
							for($y=0; $y<3; $y++) {
								 echo("<td><input id='row" . $i . $y . "' name='row[" . $i . "][" . $y . "]' type='text' size='30' maxlength='75' value='' /></td>\
");	
							}
							echo("</tr>");
						}
						
?>

I want to retain the value of the input fields after submit. Normally when I want to do so, I add this code:

value="<?php echo($formData['row'][0][0]); ?>"

but since I already have a php tag open when creating the rows, I cannot add another php tag in the value attribute. I’ve tried removing the php and echo statements, but still get an error.

Any idea on how to retain the value?

Thanks

glad that you’ve figured out the last error CathyM :slight_smile:

in case you don’t need to display E_NOTICE level errors, put this in


error_reporting(E_ALL ^ E_NOTICE);

Thanks, worked perfectly!

isset($formData[‘row’][0][0]); took out the error.

One other question,
The variable formdata is the array that holds the information from the form when submit is clicked. When the form is first shown on the screen, $formData array is empty, so now I get an undefined index error. I’ve tried putting $formData[‘row’] = array(); at the top of the page, but still get an error.
Options?

Thanks


echo("<td><input id='row" . $i . $y . "' name='row[" . $i . "][" . $y . "]' type='text' size='30' maxlength='75' value='" . $formData['row'][0][0] . "' /></td>\
");