1

I have something like this in my code:

<?php 
foreach ($tomb2[1] as $key => $metaname){
    $talalat = $tomb[1][$key]; 
    echo '<p>' . "$metaname\n" . '</p>' . '<br>' . '<input type="text" name="metavalue[]" value="' . "$talalat\n" . '">' . '<br>';
}
?>    
<input type="submit" name="Generálás" value="insert" onclick="insert()" />
</form>

I try to echo the several different values, however I get only the last one. Possibly the array contains only the last one. What am I doing wrong?

2
  • Can you print_r($tomb2)? Commented Nov 26, 2015 at 23:17
  • yes, that part is okay. My problem is when I try to do something like this: $ertekek = $_GET["metavalue"]; echo $ertekek; . I also tried foreach. Commented Nov 26, 2015 at 23:30

2 Answers 2

1

if you use a post method in form then you have to written $ertekek = $_POST["metavalue"] instead of $_GET["metavalue"] and then use print_r($ertekek) instead of echo $ertekek;

Sign up to request clarification or add additional context in comments.

1 Comment

what is $tomb variable contains?
1

You have written $talalat = $tomb[1][$key]; instead of $talalat = $tomb2[1][$key];

2 Comments

That part is completely ok and working. I have the other problem I mentioned in my other comment.
Is the action on your form set to get or absent and not set to post? Also if you look at the source of your page is it showing properly?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.