Can't display button after every post

So I'm trying to display a delete button after every post. Here's my issue. For some reason it will never show, no matter what I do. Here's my code to display the post

<?php while($row = $stmt->fetch(PDO::FETCH_ASSOC)){
     echo $post = $row['post_content'].'-'.$row['post_date']."<hr>";
}
?>

And for the delete button

<input name="Submit2" type="button" class="button" onclick="javascript:location.href='delete.php?id=<?php echo $row['id'];?>';" value="&laquo; Back" />

I'm trying to pass in the ID from the result,so I'd assume that the code has to be in somewhere in while section. Any help would be great.

Answers


Put the <input ... in the loop.

If its an issue with syntax the you simply need to escape dependent on which quotes you define the string with.

<?php 
while($row = $stmt->fetch(PDO::FETCH_ASSOC))
{
     echo $row['post_content'].' - '.$row['post_date'].'
     <input name="Submit2" type="button" class="button" onclick="javascript:location.href=\'delete.php?id='.$row['id'].'\';" value="&laquo; Back" />
     <hr>';
}
?>

or

<?php while($row = $stmt->fetch(PDO::FETCH_ASSOC)):?>
    <?php echo $row['post_content'].' - '.$row['post_date']; ?> 
    <input name="Submit2" type="button" class="button" onclick="javascript:location.href='delete.php?id=<?php echo $row['id'];?>';" value="&laquo; Back" />
    <hr>
<?php endwhile; ?>

Lots of ways really, hope it helps


Need Your Help

Command line to delete matching files and directories recursively

svn command-line file recursion dos

How can I recursively delete all files &amp; directories that match a certain pattern? e.g. remove all the ".svn" directories and the files they contain?

How do I convert a Nokogiri statement into Mechanize for screen scraping?

ruby-on-rails ruby nokogiri mechanize mechanize-ruby

I'm trying to use Mechanize to scape some tags from a page. I've used Nokogiri successfully to scrape them before, but now I'm trying to combine them into a wider Mechanize class. Here is the Nokog...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.