In the code below, I am trying to use echo $r_id[$d_id]['name'];"
where $r_id = china
and $d_id = china1
was defined in a previous page, so as to replicate echo $china['china1']['name'];
, which will give me the value of Beef and Broccoli from the array.
<?php
$china = array(
'china1'=> array(
'cat'=> "Chinese",
'id'=>"C1",
'name'=>"Beef and Broccoli",
'instruction'=> "Placeholder")
);
if(isset($_GET["r_id"])){
if(isset($_GET["d_id"])){
$r_id = $_GET["r_id"];
$d_id = $_GET["d_id"];
}
}
echo $r_id[$d_id]['name'];
?>
But all I am getting is this:
Warning: Illegal string offset 'china1' in....
Warning: Illegal string offset 'name' in....
Where did I get it wrong? Code for the previous page:
<table border = 1px align = center style = "margin-top:100px;">
<tr>
<td><a href="recipes.php?r_id=china&d_id=china1"><img src="images/china1icon.jpg"/></a></td>
<td><img src="images/vietnam1icon.jpg"/></td>
<td><img src ="images/japan1icon.jpg"/></td>
<td><img src ="images/korea1icon.jpg"/></td>
</tr>
</table>