user2666249
user2666249

Reputation: 117

Cant echo multiple values in array

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?

Upvotes: 1

Views: 153

Answers (2)

Nirali Kavar
Nirali Kavar

Reputation: 986

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;

Upvotes: 1

Johnny Dew
Johnny Dew

Reputation: 981

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

Upvotes: 1

Related Questions