Hi There I have a table that iterates like so
<form method="get" action="search">
<table class="bordered">
<thead>
<tr><th>No.</th><th>Post Username</th><th>Post Title</th><th>Post</th><th>Delete This post</th><td>Update This Post</td></tr>
</thead>
<tbody>
@foreach ($posts as $post)
<tr>
<td>{{{ $post->id }}}</td>
<td>{{{ $post->post_username }}}</td>
<td>{{{ $post->post_title }}}</td>
<td>{{{ $post->post_message }}}</td>
<td>
<form method="post" action="{{{ url('delete_post_action') }}}">
<input type="submit" value="{{ $post->id }}">Delete</td>
</form>
</td>
<td><button name="update" value="{{ $post->id }}">Update</button></td>
</tr>
@endforeach
</tbody>
</table>
</form>
Which connects to this route.
Route::post('delete_post_action', function()
{
$sql = "select * from posts";
$current_posts = DB::select($sql);
$results=$current_posts;
return View::make('pages.home')->withposts($results);
});
function delete_item($id)
{
$sql = "delete from posts where id = ?";
DB::delete($sql, array($id));
}
I have no idea why it isn't working. It refreshes the page as intended and updates the table. But it is not deleting any rows!
Aucun commentaire:
Enregistrer un commentaire