How to remove a record by id in Codeigniter
I am creating a function to remove a record in Codeigniter, but it is not working properly.
This is my buttons on properties_list
<th>
<div><a title="Delete" class="delete btn btn-sm btn-danger pull-right '.$disabled.'" data-href="'.base_url('admin/properties/del/'.$row['id']).'" data-toggle="modal" data-target="#confirm-delete"> <i class="material-icons">delete</i></a></div>
</th>
And my function DELETE on my controller Properties_php
public function del($id = 0){
$this->db->delete('ci_properties', array('propertie_id' => $id));
$this->session->set_flashdata('msg', 'Imóvel removido!');
redirect(base_url('admin/properties'));
}
php mysql codeigniter
add a comment |
I am creating a function to remove a record in Codeigniter, but it is not working properly.
This is my buttons on properties_list
<th>
<div><a title="Delete" class="delete btn btn-sm btn-danger pull-right '.$disabled.'" data-href="'.base_url('admin/properties/del/'.$row['id']).'" data-toggle="modal" data-target="#confirm-delete"> <i class="material-icons">delete</i></a></div>
</th>
And my function DELETE on my controller Properties_php
public function del($id = 0){
$this->db->delete('ci_properties', array('propertie_id' => $id));
$this->session->set_flashdata('msg', 'Imóvel removido!');
redirect(base_url('admin/properties'));
}
php mysql codeigniter
add a comment |
I am creating a function to remove a record in Codeigniter, but it is not working properly.
This is my buttons on properties_list
<th>
<div><a title="Delete" class="delete btn btn-sm btn-danger pull-right '.$disabled.'" data-href="'.base_url('admin/properties/del/'.$row['id']).'" data-toggle="modal" data-target="#confirm-delete"> <i class="material-icons">delete</i></a></div>
</th>
And my function DELETE on my controller Properties_php
public function del($id = 0){
$this->db->delete('ci_properties', array('propertie_id' => $id));
$this->session->set_flashdata('msg', 'Imóvel removido!');
redirect(base_url('admin/properties'));
}
php mysql codeigniter
I am creating a function to remove a record in Codeigniter, but it is not working properly.
This is my buttons on properties_list
<th>
<div><a title="Delete" class="delete btn btn-sm btn-danger pull-right '.$disabled.'" data-href="'.base_url('admin/properties/del/'.$row['id']).'" data-toggle="modal" data-target="#confirm-delete"> <i class="material-icons">delete</i></a></div>
</th>
And my function DELETE on my controller Properties_php
public function del($id = 0){
$this->db->delete('ci_properties', array('propertie_id' => $id));
$this->session->set_flashdata('msg', 'Imóvel removido!');
redirect(base_url('admin/properties'));
}
php mysql codeigniter
php mysql codeigniter
asked Nov 22 '18 at 0:46
MKOTMKOT
183114
183114
add a comment |
add a comment |
8 Answers
8
active
oldest
votes
try this:
<a title="Delete" class="delete btn btn-sm btn-danger pull-right '.$disabled.'" data-href="<?php echo base_url('admin/properties/del/'.$row['id']);?>" data-toggle="modal" data-target="#confirm-delete"> <i class="material-icons">delete</i></a>
add a comment |
define a var like $url
then place it in the href tag
<th>
<div>
<?php $url = base_url('admin/properties/del/'.$row['id']);?>
<a title="Delete" class="delete btn btn-sm btn-danger pull-right '.$disabled.'"
data-href="<?=$url?>" data-toggle="modal" data-target="#confirm-delete"> <i
class="material-icons">delete</i></a>
</div>
</th>
add a comment |
Try this:
<a href="<?php
echo base_url();
?>/admin/properties/del/<?php
echo $row['id'];
?>" type="button" class="btn btn-danger" style="margin-left: 5px;">Delete</a>
Can you add some explanation to your code such that others can learn from it?
– Nico Haase
Nov 22 '18 at 7:20
add a comment |
<th>
<div><a title="Delete" class="delete btn btn-sm btn-danger pull-right '.$disabled.'" data-href="<?php echo base_url();?>admin/properties/del/<?php echo $row['id']; ?>" data-toggle="modal" data-target="#confirm-delete"> <i class="material-icons">delete</i></a></div>
</th>
if this gives you an error, maybe your controller name doesn't match with link in data-href.
add a comment |
Try this:
<th>
<div>
<a title="Delete"
class="delete btn btn-sm btn-danger pull-right <?=$disabled?>"
data-href="<?=site_url('admin/properties/del/'.$row['id'])?>"
data-toggle="modal"
data-target="#confirm-delete">
<i class="material-icons">delete</i>
</a>
</div>
</th>
add a comment |
Try the Below code
delete
function fnDelete(id)
{
$.ajax({
url: "<?php echo site_url('admin/properties/del'); ?>",
method: 'POST',
data: { Autoid: id },
success:function(result) {
window.location.href= "<?php echo site_url('admin/properties'); ?>";
}
});
}
public function del(){
$id=$this->input->post('Autoid');
$this->db->delete('ci_properties', array('propertie_id' => $id));
$this->session->set_flashdata('msg', 'Imóvel removido!');
redirect(base_url('admin/properties'));
}
add a comment |
In your initial request you are sending unprocessed PHP as the url.
use
<?= $variable;?>
<?= function();?>
to process the link contents in the php view.
add a comment |
I solved like this
<div><a title="Delete" class="delete btn btn-sm btn-danger pull-right '.$disabled.'" data-href="<?php echo base_url('admin/properties/del/'.$properties['propertie_id']);?>" data-toggle="modal" data-target="#confirm-delete"> <i class="material-icons">delete</i></a></div>
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53422427%2fhow-to-remove-a-record-by-id-in-codeigniter%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
8 Answers
8
active
oldest
votes
8 Answers
8
active
oldest
votes
active
oldest
votes
active
oldest
votes
try this:
<a title="Delete" class="delete btn btn-sm btn-danger pull-right '.$disabled.'" data-href="<?php echo base_url('admin/properties/del/'.$row['id']);?>" data-toggle="modal" data-target="#confirm-delete"> <i class="material-icons">delete</i></a>
add a comment |
try this:
<a title="Delete" class="delete btn btn-sm btn-danger pull-right '.$disabled.'" data-href="<?php echo base_url('admin/properties/del/'.$row['id']);?>" data-toggle="modal" data-target="#confirm-delete"> <i class="material-icons">delete</i></a>
add a comment |
try this:
<a title="Delete" class="delete btn btn-sm btn-danger pull-right '.$disabled.'" data-href="<?php echo base_url('admin/properties/del/'.$row['id']);?>" data-toggle="modal" data-target="#confirm-delete"> <i class="material-icons">delete</i></a>
try this:
<a title="Delete" class="delete btn btn-sm btn-danger pull-right '.$disabled.'" data-href="<?php echo base_url('admin/properties/del/'.$row['id']);?>" data-toggle="modal" data-target="#confirm-delete"> <i class="material-icons">delete</i></a>
answered Nov 22 '18 at 4:41
PHP GeekPHP Geek
1,2221717
1,2221717
add a comment |
add a comment |
define a var like $url
then place it in the href tag
<th>
<div>
<?php $url = base_url('admin/properties/del/'.$row['id']);?>
<a title="Delete" class="delete btn btn-sm btn-danger pull-right '.$disabled.'"
data-href="<?=$url?>" data-toggle="modal" data-target="#confirm-delete"> <i
class="material-icons">delete</i></a>
</div>
</th>
add a comment |
define a var like $url
then place it in the href tag
<th>
<div>
<?php $url = base_url('admin/properties/del/'.$row['id']);?>
<a title="Delete" class="delete btn btn-sm btn-danger pull-right '.$disabled.'"
data-href="<?=$url?>" data-toggle="modal" data-target="#confirm-delete"> <i
class="material-icons">delete</i></a>
</div>
</th>
add a comment |
define a var like $url
then place it in the href tag
<th>
<div>
<?php $url = base_url('admin/properties/del/'.$row['id']);?>
<a title="Delete" class="delete btn btn-sm btn-danger pull-right '.$disabled.'"
data-href="<?=$url?>" data-toggle="modal" data-target="#confirm-delete"> <i
class="material-icons">delete</i></a>
</div>
</th>
define a var like $url
then place it in the href tag
<th>
<div>
<?php $url = base_url('admin/properties/del/'.$row['id']);?>
<a title="Delete" class="delete btn btn-sm btn-danger pull-right '.$disabled.'"
data-href="<?=$url?>" data-toggle="modal" data-target="#confirm-delete"> <i
class="material-icons">delete</i></a>
</div>
</th>
answered Nov 22 '18 at 6:39
JustinJustin
523
523
add a comment |
add a comment |
Try this:
<a href="<?php
echo base_url();
?>/admin/properties/del/<?php
echo $row['id'];
?>" type="button" class="btn btn-danger" style="margin-left: 5px;">Delete</a>
Can you add some explanation to your code such that others can learn from it?
– Nico Haase
Nov 22 '18 at 7:20
add a comment |
Try this:
<a href="<?php
echo base_url();
?>/admin/properties/del/<?php
echo $row['id'];
?>" type="button" class="btn btn-danger" style="margin-left: 5px;">Delete</a>
Can you add some explanation to your code such that others can learn from it?
– Nico Haase
Nov 22 '18 at 7:20
add a comment |
Try this:
<a href="<?php
echo base_url();
?>/admin/properties/del/<?php
echo $row['id'];
?>" type="button" class="btn btn-danger" style="margin-left: 5px;">Delete</a>
Try this:
<a href="<?php
echo base_url();
?>/admin/properties/del/<?php
echo $row['id'];
?>" type="button" class="btn btn-danger" style="margin-left: 5px;">Delete</a>
edited Nov 22 '18 at 8:10
Ahmad
8,21543463
8,21543463
answered Nov 22 '18 at 5:27
ManiMani
24726
24726
Can you add some explanation to your code such that others can learn from it?
– Nico Haase
Nov 22 '18 at 7:20
add a comment |
Can you add some explanation to your code such that others can learn from it?
– Nico Haase
Nov 22 '18 at 7:20
Can you add some explanation to your code such that others can learn from it?
– Nico Haase
Nov 22 '18 at 7:20
Can you add some explanation to your code such that others can learn from it?
– Nico Haase
Nov 22 '18 at 7:20
add a comment |
<th>
<div><a title="Delete" class="delete btn btn-sm btn-danger pull-right '.$disabled.'" data-href="<?php echo base_url();?>admin/properties/del/<?php echo $row['id']; ?>" data-toggle="modal" data-target="#confirm-delete"> <i class="material-icons">delete</i></a></div>
</th>
if this gives you an error, maybe your controller name doesn't match with link in data-href.
add a comment |
<th>
<div><a title="Delete" class="delete btn btn-sm btn-danger pull-right '.$disabled.'" data-href="<?php echo base_url();?>admin/properties/del/<?php echo $row['id']; ?>" data-toggle="modal" data-target="#confirm-delete"> <i class="material-icons">delete</i></a></div>
</th>
if this gives you an error, maybe your controller name doesn't match with link in data-href.
add a comment |
<th>
<div><a title="Delete" class="delete btn btn-sm btn-danger pull-right '.$disabled.'" data-href="<?php echo base_url();?>admin/properties/del/<?php echo $row['id']; ?>" data-toggle="modal" data-target="#confirm-delete"> <i class="material-icons">delete</i></a></div>
</th>
if this gives you an error, maybe your controller name doesn't match with link in data-href.
<th>
<div><a title="Delete" class="delete btn btn-sm btn-danger pull-right '.$disabled.'" data-href="<?php echo base_url();?>admin/properties/del/<?php echo $row['id']; ?>" data-toggle="modal" data-target="#confirm-delete"> <i class="material-icons">delete</i></a></div>
</th>
if this gives you an error, maybe your controller name doesn't match with link in data-href.
answered Nov 22 '18 at 8:44
Rizki MasjahriRizki Masjahri
214
214
add a comment |
add a comment |
Try this:
<th>
<div>
<a title="Delete"
class="delete btn btn-sm btn-danger pull-right <?=$disabled?>"
data-href="<?=site_url('admin/properties/del/'.$row['id'])?>"
data-toggle="modal"
data-target="#confirm-delete">
<i class="material-icons">delete</i>
</a>
</div>
</th>
add a comment |
Try this:
<th>
<div>
<a title="Delete"
class="delete btn btn-sm btn-danger pull-right <?=$disabled?>"
data-href="<?=site_url('admin/properties/del/'.$row['id'])?>"
data-toggle="modal"
data-target="#confirm-delete">
<i class="material-icons">delete</i>
</a>
</div>
</th>
add a comment |
Try this:
<th>
<div>
<a title="Delete"
class="delete btn btn-sm btn-danger pull-right <?=$disabled?>"
data-href="<?=site_url('admin/properties/del/'.$row['id'])?>"
data-toggle="modal"
data-target="#confirm-delete">
<i class="material-icons">delete</i>
</a>
</div>
</th>
Try this:
<th>
<div>
<a title="Delete"
class="delete btn btn-sm btn-danger pull-right <?=$disabled?>"
data-href="<?=site_url('admin/properties/del/'.$row['id'])?>"
data-toggle="modal"
data-target="#confirm-delete">
<i class="material-icons">delete</i>
</a>
</div>
</th>
edited Nov 22 '18 at 9:52
Philipp Kief
2,57611831
2,57611831
answered Nov 22 '18 at 4:28
Vijay SharmaVijay Sharma
668610
668610
add a comment |
add a comment |
Try the Below code
delete
function fnDelete(id)
{
$.ajax({
url: "<?php echo site_url('admin/properties/del'); ?>",
method: 'POST',
data: { Autoid: id },
success:function(result) {
window.location.href= "<?php echo site_url('admin/properties'); ?>";
}
});
}
public function del(){
$id=$this->input->post('Autoid');
$this->db->delete('ci_properties', array('propertie_id' => $id));
$this->session->set_flashdata('msg', 'Imóvel removido!');
redirect(base_url('admin/properties'));
}
add a comment |
Try the Below code
delete
function fnDelete(id)
{
$.ajax({
url: "<?php echo site_url('admin/properties/del'); ?>",
method: 'POST',
data: { Autoid: id },
success:function(result) {
window.location.href= "<?php echo site_url('admin/properties'); ?>";
}
});
}
public function del(){
$id=$this->input->post('Autoid');
$this->db->delete('ci_properties', array('propertie_id' => $id));
$this->session->set_flashdata('msg', 'Imóvel removido!');
redirect(base_url('admin/properties'));
}
add a comment |
Try the Below code
delete
function fnDelete(id)
{
$.ajax({
url: "<?php echo site_url('admin/properties/del'); ?>",
method: 'POST',
data: { Autoid: id },
success:function(result) {
window.location.href= "<?php echo site_url('admin/properties'); ?>";
}
});
}
public function del(){
$id=$this->input->post('Autoid');
$this->db->delete('ci_properties', array('propertie_id' => $id));
$this->session->set_flashdata('msg', 'Imóvel removido!');
redirect(base_url('admin/properties'));
}
Try the Below code
delete
function fnDelete(id)
{
$.ajax({
url: "<?php echo site_url('admin/properties/del'); ?>",
method: 'POST',
data: { Autoid: id },
success:function(result) {
window.location.href= "<?php echo site_url('admin/properties'); ?>";
}
});
}
public function del(){
$id=$this->input->post('Autoid');
$this->db->delete('ci_properties', array('propertie_id' => $id));
$this->session->set_flashdata('msg', 'Imóvel removido!');
redirect(base_url('admin/properties'));
}
answered Nov 22 '18 at 11:59
Brindha BaskaranBrindha Baskaran
9510
9510
add a comment |
add a comment |
In your initial request you are sending unprocessed PHP as the url.
use
<?= $variable;?>
<?= function();?>
to process the link contents in the php view.
add a comment |
In your initial request you are sending unprocessed PHP as the url.
use
<?= $variable;?>
<?= function();?>
to process the link contents in the php view.
add a comment |
In your initial request you are sending unprocessed PHP as the url.
use
<?= $variable;?>
<?= function();?>
to process the link contents in the php view.
In your initial request you are sending unprocessed PHP as the url.
use
<?= $variable;?>
<?= function();?>
to process the link contents in the php view.
answered Nov 22 '18 at 21:07
AlunRAlunR
425310
425310
add a comment |
add a comment |
I solved like this
<div><a title="Delete" class="delete btn btn-sm btn-danger pull-right '.$disabled.'" data-href="<?php echo base_url('admin/properties/del/'.$properties['propertie_id']);?>" data-toggle="modal" data-target="#confirm-delete"> <i class="material-icons">delete</i></a></div>
add a comment |
I solved like this
<div><a title="Delete" class="delete btn btn-sm btn-danger pull-right '.$disabled.'" data-href="<?php echo base_url('admin/properties/del/'.$properties['propertie_id']);?>" data-toggle="modal" data-target="#confirm-delete"> <i class="material-icons">delete</i></a></div>
add a comment |
I solved like this
<div><a title="Delete" class="delete btn btn-sm btn-danger pull-right '.$disabled.'" data-href="<?php echo base_url('admin/properties/del/'.$properties['propertie_id']);?>" data-toggle="modal" data-target="#confirm-delete"> <i class="material-icons">delete</i></a></div>
I solved like this
<div><a title="Delete" class="delete btn btn-sm btn-danger pull-right '.$disabled.'" data-href="<?php echo base_url('admin/properties/del/'.$properties['propertie_id']);?>" data-toggle="modal" data-target="#confirm-delete"> <i class="material-icons">delete</i></a></div>
answered Nov 22 '18 at 22:30
MKOTMKOT
183114
183114
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53422427%2fhow-to-remove-a-record-by-id-in-codeigniter%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown