如何在php中嵌套php变量

I want to use this variable:

$id= $row['property_id'];

Inside this href after the equals sign after 'id'

echo "<td>""<a href='product_description.php?id='>" . $row['PropertyType'] . "</a></td>";

How can I do this? I think it may be a problem with escaping quotes but I can't seem to find a solution. I'm new to php and would appreciate the help

Do it like this:

echo '<td><a href="product_description.php?id=' . $id . '" >' . $row['PropertyType'] . '</a></td>';

You should also think about echoing the data in the html, instead of echoing out html itself. It is a lot cleaner.

e.g. you can do the above like this:

<?php
   // your php, ready up the data. your $id and $row
?> <!-- close your php tag -->
<td>
   <a href="product_description.php?id=<?= $id ?>" >
      <?= $row['PropertyType'] ?>
   </a>
</td>

Note: that <?= $var ?> is equivalent to <?php echo $var ?>.

Hope this helps.

You only need to put your variable same as PropertyType which you wrote. Please find below syntex:

echo "<td><a href='product_description.php?id=" . $id . "'>" . $row['PropertyType'] . "</a></td>";

I guess you need something like this (variable variables):

$var_id = 'id';
$$var_id = 'something';

print_r($id);
print_r($var_id);

Will give you

something
id

in output respectively. So you can use it like:

$var_id = $row['property_id'];
$$var_id = 'id';

echo '<td><a href="product_description.php?'.$var_id.'='.$id.'">'.$id.'</a></td>';

That will generate a link that leads to:

http://example.com/product_description.php?id=property_id

Or simply

$id= $row['property_id'];
echo '<td><a href="product_description.php?id='.$id.'">'.$id.'</a></td>';