mardi 14 avril 2015

Delete from Laravel Database using button

Im trying to delete rows from an sqlite database and then refresh the page. This should all happen when i click the button(shown bellow).


Button:



<button type="button" class="btn btn-danger" onclick= "{{{ url("delete_item_action/$post->Id") }}}">Delete</button>


Here are the functions that should execute the sql query delete:



function delete_Post($id)
{
$sql = "delete FROM Post WHERE id = ?";
DB::delete($sql, array($id));
}
function delete_item_action($id)
{
delete_Post($id);
return View::make('social.home');
}

Aucun commentaire:

Enregistrer un commentaire