Manuel Mahler Manuel Mahler - 1 month ago 5
PHP Question

echo/quotation marks with table in php

I have a html table in which i show data from mysql database.

echo "<td>".$zeile['zielort']."</td>";

This works fine.
Now im trying to add a link in a other td to call my delete function in deletefahrt.php

echo "<td>" <a href=deletefahrt.php?del='.$zeile['id'].'> "Delete"</a> "</td>";

It doesnt work and i assume there are some mistake with
quotation marks.

Hope you can help me out :)



If you're using double quotes around the entire string, you can use the variable inside the string like so (called string interpolation) [Note: must use double quotes to use string interpolation in PHP):

echo "<td><a href='deletefahrt.php?del={$zeile['id']}'>Delete</a></td>";

Another way to solve this issue would be sprintf like so:

echo sprintf("<td><a href='deletefahrt.php?del=%s'>Delete</a></td>", $zeile['id']);

Overall, if you still wanted to use concat to place the variable in the string, you could do it like so:

echo "<td><a href='deletefahrt.php?del=" . $zeile['id'] . "'>Delete</a></td>";

My personal code style would probably use string interpolation (option 1).


I also recommend getting yourself an IDE of some sort...

My personal favorite is PHPStorm as it is rather feature rich, but it's heavy on system resources. There is a 30 day trial on that download

The best free and easy IDE that will at least get you some syntax highlighting would probably be Atom, which is comprable to Sublime Text (not free)

If you had some sort of IDE, you probably would have realized you original issue right off the bat.