Jump to content

PHP array


Recommended Posts

Hello everyone.I am learning arrays in PHP.I tried to take 6 text inputs and store it ina a array and then display when we click submit button.But I am not getting output.Below is my code.Please help me out.

<html>
<head>
<title>
List Function
</title>
</head>
<body>
<?php
if(isset($_POST['posted']))
{
	for($count=0;$count<=5;$count++)
	{
		$a = $_POST['hidden'][$count];
		echo "$a<br/>";
	}
}
?>
	


<form method = "POST" action = "listfunction.php">
<input type = "hidden" name = "posted" value = "true"/>
<?php
for($counter=0;$counter<=5;$counter++)
{
	echo "<input type = 'text' name = '$array[$counter]'><br/>";
	echo "<input type = 'hidden' name = 'hidden[]' value = '$array[$counter]'>";
}

?>
<input type = "submit" value = "submit"/>
</body>
</html>

Thank you.

Link to comment
https://forums.phpfreaks.com/topic/280686-php-array/
Share on other sites

Well just tell me how to take inputs,store it in array and then display it when clicked 'submit'.

 

Kind of demanding and uninformative:

if(isset($_POST['posted']))
{
	print_r($_POST);
}
?>
<form method = "POST" action = "listfunction.php">
<input type = "hidden" name = "posted" value = "true"/>
<?php
for($counter=0;$counter<=5;$counter++)
{
	echo "<input type = 'text' name = 'text[]'><br/>";
	echo "<input type = 'hidden' name = 'hidden[]' value = '$counter whatever you want'>";
}
?>
<input type = "submit" value = "submit"/>
</form>
Link to comment
https://forums.phpfreaks.com/topic/280686-php-array/#findComment-1443693
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.