Search code examples
phpparsingsyntaxquotes

Syntax error php, not sure how to include an edit button with every record returned


I am currently retrieving records from a database, however I am implementing an edit button so you are able to edit the record information however I cant seem to find where I am going wrong with my syntax? if anyone could help me, I would greatly appreciate it.

my code:

.'</td><td><a href="editmp3.php?edit_id='.$row['mp3id'].'" alt="edit" >Edit</a></td>   <td><a href="deletedmp3.php?delete_id='.$row['mp3id'].'" alt="delete" >Delete</a></td><td></tr>';

When I click the delete button it tries to find the edit_id. not sure why


Solution

  • Try this:

    echo '<tr><td><a href="./metadata images/'. $row["Title"] .'">'. $row["Title"] ."</td><td>". $row["Author"] ."</td><td>". $row["AlbumAuthor"] ."</td><td>".$row["Year"]."</td><td>".$row["Genre"] .'</td><td><a href="editItem.php?edit_id='.$row['itemID'].'" alt="edit" >Edit</a></td><td></tr>';
    

    it looks like you're already in a php block, and then you're declaring another php block within an echo statement.

    I highly recommend if you're going to develop php you work in some sort of framework that does not require you to mix between <?php ?> and <html> and whatever else. stay in one language and use functions, classes, templates, frameworks and so on to construct views like this.