I am having some problem with associative array. When I check the array $keywordstoupdate does return a value but when it reaches to echo it say Keyword is undefined. However, print_r() prints it and everything is fine from that perspective. but when I try to echo then the Keyword is missing.
function getkeywords($mysqli, $someid)
{
$keywords=array();
$query='select Keyword from keywords where someId=?';
$stmt= $mysqli->stmt_init();
$stmt->prepare($query);
$stmt->bind_param('i', $someid);
$stmt->execute();
$stmt->bind_result($Keyword);
while($stmt->fetch())
{
$keywords[]= array("Keyword" => $Keyword);
}
return $keywords;
}
$keywordstoupdate[]=getkeywords($mysqli, $someid);
<textarea id='textarea_keywords' name='keywords'>
<?php
if(count($keywordstoupdate)>0){
for($i=0; count($keywordstoupdate)>$i; $i++){
echo ( $keywordstoupdate[$i]['Keyword']." ");
}
} ?></textarea>
The result of print_r()
Array
(
[0] => Array
(
[Keyword] => asdf
)
)
print_r()displaying?$keywordstoupdate.. and by the way I think I have been answered..