Reputation: 357
<input type="text" name="prod_id" value="<?php echo $product['table']['id']; ?>" />
But it doesn't show up anything although the $product variable is sure to have been properly initialized, what might be the problem ?
Here is the print_r produce
Array (
[0] => Array (
[product_table] => Array (
[id] => 5
[quantity] => 20
[name] => something
)
)
)
Upvotes: 0
Views: 368
Reputation: 19882
Use this
<?php
extract($product[0]);
<input type="text" name="prod_id" value="<?php echo $product_table['id']; ?>" />
Upvotes: 0
Reputation: 2113
<input type="text" name="prod_id" value="<?php echo $product[0]['product_table']['id']; ?>" />
Please add index [0] to ensure that if the provided array have multiple values then only first one will be picked as well.
Upvotes: 0
Reputation: 1268
You have to access the variable as $product[0]['product_table']['id']
and not $product['table']['id']
Upvotes: 5
Reputation: 14752
You're trying to output contents of a non-existing key. You have 'product_table', not 'table'.
Edit:
And it also needs to be $product[0]['product_table']['id']
.
Upvotes: 2