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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.