Codeigniter Delete query doesnt delete row
Im trying to delete a row from the database. After deleting, the table being displayed should refresh and shows the current database (without the deleted row).
Controller
public function delete()
{
$this->load->database();
$this->load->model('userdetailModel');
$id=$this->input->get('user_id');
$this->userdetailModel->deleteOne($id);
$data['results'] = $this->userdetailModel->viewAll();
$this->load->view('userView', $data);
}
view
<?php
foreach($results as $res): ?>
<tbody>
<tr>
<td><center><b><?php echo $res->user_id; ?></center></b></td>
<td><center><?php echo $res->first_name; ?></center></td>
<td><center><?php echo $res->last_name; ?></center></td>
<td><center><?php echo $res->gender; ?></center></td>
<td><center><a href=" <?= site_url('userController/view')?> "> View </a></center></td>
<td><center><a href=" <?= site_url('userController/edit')?> "> Edit </a></center></td>
<td><center><a href=" <?= site_url('userController/delete?id='.$res->user_id)?> "> Delete </a></center></td>
</tr>
</tbody>
<?php endforeach; ?>
</table>
</center>
} ?>
user_id is a field name from the database. I followed some source code but I can't get it right. Please further explain to me what I am lacking in this code blocks.
Model
function viewAll() {
$this->db->select('user_id, first_name, last_name, gender');
$this->db->from('user_details');
return $this->db->get()->result();
}
function deleteOne($id)
{
$this->db->select('*');
$this->db->from('user_details');
$this->db->where('user_id', $id);
$this->db->delete('user_details');
}
php codeigniter
add a comment |
Im trying to delete a row from the database. After deleting, the table being displayed should refresh and shows the current database (without the deleted row).
Controller
public function delete()
{
$this->load->database();
$this->load->model('userdetailModel');
$id=$this->input->get('user_id');
$this->userdetailModel->deleteOne($id);
$data['results'] = $this->userdetailModel->viewAll();
$this->load->view('userView', $data);
}
view
<?php
foreach($results as $res): ?>
<tbody>
<tr>
<td><center><b><?php echo $res->user_id; ?></center></b></td>
<td><center><?php echo $res->first_name; ?></center></td>
<td><center><?php echo $res->last_name; ?></center></td>
<td><center><?php echo $res->gender; ?></center></td>
<td><center><a href=" <?= site_url('userController/view')?> "> View </a></center></td>
<td><center><a href=" <?= site_url('userController/edit')?> "> Edit </a></center></td>
<td><center><a href=" <?= site_url('userController/delete?id='.$res->user_id)?> "> Delete </a></center></td>
</tr>
</tbody>
<?php endforeach; ?>
</table>
</center>
} ?>
user_id is a field name from the database. I followed some source code but I can't get it right. Please further explain to me what I am lacking in this code blocks.
Model
function viewAll() {
$this->db->select('user_id, first_name, last_name, gender');
$this->db->from('user_details');
return $this->db->get()->result();
}
function deleteOne($id)
{
$this->db->select('*');
$this->db->from('user_details');
$this->db->where('user_id', $id);
$this->db->delete('user_details');
}
php codeigniter
'id='.$res->user_id' . 'id' its your param name . But in controller you check 'user_id'
– Yaroslaw
Nov 27 '18 at 15:43
Please edit the question and include code foruserdetailMode
deleteOne()
andviewAll()
– DFriend
Nov 27 '18 at 15:44
user_id is the field name on my sql database. Im trying to delete a row from the database. After deleting, the table being displayed should refresh and shows the current database (without the deleted row).
– lolo mo
Nov 27 '18 at 15:48
@DFriend i have edited my question and the codes
– lolo mo
Nov 27 '18 at 15:57
add a comment |
Im trying to delete a row from the database. After deleting, the table being displayed should refresh and shows the current database (without the deleted row).
Controller
public function delete()
{
$this->load->database();
$this->load->model('userdetailModel');
$id=$this->input->get('user_id');
$this->userdetailModel->deleteOne($id);
$data['results'] = $this->userdetailModel->viewAll();
$this->load->view('userView', $data);
}
view
<?php
foreach($results as $res): ?>
<tbody>
<tr>
<td><center><b><?php echo $res->user_id; ?></center></b></td>
<td><center><?php echo $res->first_name; ?></center></td>
<td><center><?php echo $res->last_name; ?></center></td>
<td><center><?php echo $res->gender; ?></center></td>
<td><center><a href=" <?= site_url('userController/view')?> "> View </a></center></td>
<td><center><a href=" <?= site_url('userController/edit')?> "> Edit </a></center></td>
<td><center><a href=" <?= site_url('userController/delete?id='.$res->user_id)?> "> Delete </a></center></td>
</tr>
</tbody>
<?php endforeach; ?>
</table>
</center>
} ?>
user_id is a field name from the database. I followed some source code but I can't get it right. Please further explain to me what I am lacking in this code blocks.
Model
function viewAll() {
$this->db->select('user_id, first_name, last_name, gender');
$this->db->from('user_details');
return $this->db->get()->result();
}
function deleteOne($id)
{
$this->db->select('*');
$this->db->from('user_details');
$this->db->where('user_id', $id);
$this->db->delete('user_details');
}
php codeigniter
Im trying to delete a row from the database. After deleting, the table being displayed should refresh and shows the current database (without the deleted row).
Controller
public function delete()
{
$this->load->database();
$this->load->model('userdetailModel');
$id=$this->input->get('user_id');
$this->userdetailModel->deleteOne($id);
$data['results'] = $this->userdetailModel->viewAll();
$this->load->view('userView', $data);
}
view
<?php
foreach($results as $res): ?>
<tbody>
<tr>
<td><center><b><?php echo $res->user_id; ?></center></b></td>
<td><center><?php echo $res->first_name; ?></center></td>
<td><center><?php echo $res->last_name; ?></center></td>
<td><center><?php echo $res->gender; ?></center></td>
<td><center><a href=" <?= site_url('userController/view')?> "> View </a></center></td>
<td><center><a href=" <?= site_url('userController/edit')?> "> Edit </a></center></td>
<td><center><a href=" <?= site_url('userController/delete?id='.$res->user_id)?> "> Delete </a></center></td>
</tr>
</tbody>
<?php endforeach; ?>
</table>
</center>
} ?>
user_id is a field name from the database. I followed some source code but I can't get it right. Please further explain to me what I am lacking in this code blocks.
Model
function viewAll() {
$this->db->select('user_id, first_name, last_name, gender');
$this->db->from('user_details');
return $this->db->get()->result();
}
function deleteOne($id)
{
$this->db->select('*');
$this->db->from('user_details');
$this->db->where('user_id', $id);
$this->db->delete('user_details');
}
php codeigniter
php codeigniter
edited Nov 27 '18 at 15:56
lolo mo
asked Nov 27 '18 at 15:39
lolo mololo mo
103
103
'id='.$res->user_id' . 'id' its your param name . But in controller you check 'user_id'
– Yaroslaw
Nov 27 '18 at 15:43
Please edit the question and include code foruserdetailMode
deleteOne()
andviewAll()
– DFriend
Nov 27 '18 at 15:44
user_id is the field name on my sql database. Im trying to delete a row from the database. After deleting, the table being displayed should refresh and shows the current database (without the deleted row).
– lolo mo
Nov 27 '18 at 15:48
@DFriend i have edited my question and the codes
– lolo mo
Nov 27 '18 at 15:57
add a comment |
'id='.$res->user_id' . 'id' its your param name . But in controller you check 'user_id'
– Yaroslaw
Nov 27 '18 at 15:43
Please edit the question and include code foruserdetailMode
deleteOne()
andviewAll()
– DFriend
Nov 27 '18 at 15:44
user_id is the field name on my sql database. Im trying to delete a row from the database. After deleting, the table being displayed should refresh and shows the current database (without the deleted row).
– lolo mo
Nov 27 '18 at 15:48
@DFriend i have edited my question and the codes
– lolo mo
Nov 27 '18 at 15:57
'id='.$res->user_id' . 'id' its your param name . But in controller you check 'user_id'
– Yaroslaw
Nov 27 '18 at 15:43
'id='.$res->user_id' . 'id' its your param name . But in controller you check 'user_id'
– Yaroslaw
Nov 27 '18 at 15:43
Please edit the question and include code for
userdetailMode
deleteOne()
and viewAll()
– DFriend
Nov 27 '18 at 15:44
Please edit the question and include code for
userdetailMode
deleteOne()
and viewAll()
– DFriend
Nov 27 '18 at 15:44
user_id is the field name on my sql database. Im trying to delete a row from the database. After deleting, the table being displayed should refresh and shows the current database (without the deleted row).
– lolo mo
Nov 27 '18 at 15:48
user_id is the field name on my sql database. Im trying to delete a row from the database. After deleting, the table being displayed should refresh and shows the current database (without the deleted row).
– lolo mo
Nov 27 '18 at 15:48
@DFriend i have edited my question and the codes
– lolo mo
Nov 27 '18 at 15:57
@DFriend i have edited my question and the codes
– lolo mo
Nov 27 '18 at 15:57
add a comment |
3 Answers
3
active
oldest
votes
You can try :
$this->userdetailModel->delete($id);
or :
$this->db->delete('userdetailModel', array('user_id' => $id));
or :
function deleteOne($id)
{
$this->db->where('user_id', $id);
$this->db->delete('user_details');
}
instead of :
$this->userdetailModel->deleteOne($id);
explication:
code-igniter query builder have built in delete method. You can call it from your model. no need to have a "deletoOne" function.
And no need to make select('*') from ('X') before delete in SQL
source :
https://www.codeigniter.com/userguide3/database/query_builder.html#deleting-data
add a comment |
First, you need to fix the "delete" link where you have
<?= site_url('userController/delete?id='.$res->user_id)?>
in the view and then, in the controller you ask for user_id
$this->input->get('user_id');
Do you see the difference? You set a query item id=
but ask for (get) query item user_id
. So you need to change the code so they match. This is probably why nothing has been getting deleted. You haven't been getting the id value.
You might consider simply passing the id
in the URI like this
<?= site_url('userController/delete/'.$res->user_id)?>
And then the controller function is changed to this
public function delete($id)
{
$this->load->database();
$this->load->model('userdetailModel');
$this->userdetailModel->deleteOne($id);
$data['results'] = $this->userdetailModel->viewAll();
$this->load->view('userView', $data);
}
Note how $id
is now an argument to the function and can more easily be used.
In the deleteOne
function of the model, you have mixed up some tasks. The functions select
and from
are not used when deleting from a table.
It's a good idea to have model functions return something so the controller knows if everything worked or not.
function deleteOne($id)
{
if(empty($id))
{
return false; //oops, no data for 'where' to use
}
$result = $this->db
->where('user_id', $id)
->delete('user_details');
return $result !== false;
}
Notice we're checking incoming data item $id
. No point in running a query if there is no data the where()
can use. If $id
is empty then return false.
The function delete()
will return either an object (of type CI_DB_query_builder
) or the boolean FALSE. So the last line of code above will evaluate to a boolean, either TRUE if $result
is not false, or FALSE if it is.
By testing the model return value you can send a message to your view if there is a problem, or if the delete succeeded - whatever you think best. I'll leave using the model return in the controller to you. Hope this helps.
add a comment |
try this query in model:
function deleteOne($id){
return $this->db->where('user_id',$id)->delete('table_name');
}
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%2f53503122%2fcodeigniter-delete-query-doesnt-delete-row%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can try :
$this->userdetailModel->delete($id);
or :
$this->db->delete('userdetailModel', array('user_id' => $id));
or :
function deleteOne($id)
{
$this->db->where('user_id', $id);
$this->db->delete('user_details');
}
instead of :
$this->userdetailModel->deleteOne($id);
explication:
code-igniter query builder have built in delete method. You can call it from your model. no need to have a "deletoOne" function.
And no need to make select('*') from ('X') before delete in SQL
source :
https://www.codeigniter.com/userguide3/database/query_builder.html#deleting-data
add a comment |
You can try :
$this->userdetailModel->delete($id);
or :
$this->db->delete('userdetailModel', array('user_id' => $id));
or :
function deleteOne($id)
{
$this->db->where('user_id', $id);
$this->db->delete('user_details');
}
instead of :
$this->userdetailModel->deleteOne($id);
explication:
code-igniter query builder have built in delete method. You can call it from your model. no need to have a "deletoOne" function.
And no need to make select('*') from ('X') before delete in SQL
source :
https://www.codeigniter.com/userguide3/database/query_builder.html#deleting-data
add a comment |
You can try :
$this->userdetailModel->delete($id);
or :
$this->db->delete('userdetailModel', array('user_id' => $id));
or :
function deleteOne($id)
{
$this->db->where('user_id', $id);
$this->db->delete('user_details');
}
instead of :
$this->userdetailModel->deleteOne($id);
explication:
code-igniter query builder have built in delete method. You can call it from your model. no need to have a "deletoOne" function.
And no need to make select('*') from ('X') before delete in SQL
source :
https://www.codeigniter.com/userguide3/database/query_builder.html#deleting-data
You can try :
$this->userdetailModel->delete($id);
or :
$this->db->delete('userdetailModel', array('user_id' => $id));
or :
function deleteOne($id)
{
$this->db->where('user_id', $id);
$this->db->delete('user_details');
}
instead of :
$this->userdetailModel->deleteOne($id);
explication:
code-igniter query builder have built in delete method. You can call it from your model. no need to have a "deletoOne" function.
And no need to make select('*') from ('X') before delete in SQL
source :
https://www.codeigniter.com/userguide3/database/query_builder.html#deleting-data
edited Nov 27 '18 at 16:14
answered Nov 27 '18 at 16:02
Nicolas De TiesenhausenNicolas De Tiesenhausen
366
366
add a comment |
add a comment |
First, you need to fix the "delete" link where you have
<?= site_url('userController/delete?id='.$res->user_id)?>
in the view and then, in the controller you ask for user_id
$this->input->get('user_id');
Do you see the difference? You set a query item id=
but ask for (get) query item user_id
. So you need to change the code so they match. This is probably why nothing has been getting deleted. You haven't been getting the id value.
You might consider simply passing the id
in the URI like this
<?= site_url('userController/delete/'.$res->user_id)?>
And then the controller function is changed to this
public function delete($id)
{
$this->load->database();
$this->load->model('userdetailModel');
$this->userdetailModel->deleteOne($id);
$data['results'] = $this->userdetailModel->viewAll();
$this->load->view('userView', $data);
}
Note how $id
is now an argument to the function and can more easily be used.
In the deleteOne
function of the model, you have mixed up some tasks. The functions select
and from
are not used when deleting from a table.
It's a good idea to have model functions return something so the controller knows if everything worked or not.
function deleteOne($id)
{
if(empty($id))
{
return false; //oops, no data for 'where' to use
}
$result = $this->db
->where('user_id', $id)
->delete('user_details');
return $result !== false;
}
Notice we're checking incoming data item $id
. No point in running a query if there is no data the where()
can use. If $id
is empty then return false.
The function delete()
will return either an object (of type CI_DB_query_builder
) or the boolean FALSE. So the last line of code above will evaluate to a boolean, either TRUE if $result
is not false, or FALSE if it is.
By testing the model return value you can send a message to your view if there is a problem, or if the delete succeeded - whatever you think best. I'll leave using the model return in the controller to you. Hope this helps.
add a comment |
First, you need to fix the "delete" link where you have
<?= site_url('userController/delete?id='.$res->user_id)?>
in the view and then, in the controller you ask for user_id
$this->input->get('user_id');
Do you see the difference? You set a query item id=
but ask for (get) query item user_id
. So you need to change the code so they match. This is probably why nothing has been getting deleted. You haven't been getting the id value.
You might consider simply passing the id
in the URI like this
<?= site_url('userController/delete/'.$res->user_id)?>
And then the controller function is changed to this
public function delete($id)
{
$this->load->database();
$this->load->model('userdetailModel');
$this->userdetailModel->deleteOne($id);
$data['results'] = $this->userdetailModel->viewAll();
$this->load->view('userView', $data);
}
Note how $id
is now an argument to the function and can more easily be used.
In the deleteOne
function of the model, you have mixed up some tasks. The functions select
and from
are not used when deleting from a table.
It's a good idea to have model functions return something so the controller knows if everything worked or not.
function deleteOne($id)
{
if(empty($id))
{
return false; //oops, no data for 'where' to use
}
$result = $this->db
->where('user_id', $id)
->delete('user_details');
return $result !== false;
}
Notice we're checking incoming data item $id
. No point in running a query if there is no data the where()
can use. If $id
is empty then return false.
The function delete()
will return either an object (of type CI_DB_query_builder
) or the boolean FALSE. So the last line of code above will evaluate to a boolean, either TRUE if $result
is not false, or FALSE if it is.
By testing the model return value you can send a message to your view if there is a problem, or if the delete succeeded - whatever you think best. I'll leave using the model return in the controller to you. Hope this helps.
add a comment |
First, you need to fix the "delete" link where you have
<?= site_url('userController/delete?id='.$res->user_id)?>
in the view and then, in the controller you ask for user_id
$this->input->get('user_id');
Do you see the difference? You set a query item id=
but ask for (get) query item user_id
. So you need to change the code so they match. This is probably why nothing has been getting deleted. You haven't been getting the id value.
You might consider simply passing the id
in the URI like this
<?= site_url('userController/delete/'.$res->user_id)?>
And then the controller function is changed to this
public function delete($id)
{
$this->load->database();
$this->load->model('userdetailModel');
$this->userdetailModel->deleteOne($id);
$data['results'] = $this->userdetailModel->viewAll();
$this->load->view('userView', $data);
}
Note how $id
is now an argument to the function and can more easily be used.
In the deleteOne
function of the model, you have mixed up some tasks. The functions select
and from
are not used when deleting from a table.
It's a good idea to have model functions return something so the controller knows if everything worked or not.
function deleteOne($id)
{
if(empty($id))
{
return false; //oops, no data for 'where' to use
}
$result = $this->db
->where('user_id', $id)
->delete('user_details');
return $result !== false;
}
Notice we're checking incoming data item $id
. No point in running a query if there is no data the where()
can use. If $id
is empty then return false.
The function delete()
will return either an object (of type CI_DB_query_builder
) or the boolean FALSE. So the last line of code above will evaluate to a boolean, either TRUE if $result
is not false, or FALSE if it is.
By testing the model return value you can send a message to your view if there is a problem, or if the delete succeeded - whatever you think best. I'll leave using the model return in the controller to you. Hope this helps.
First, you need to fix the "delete" link where you have
<?= site_url('userController/delete?id='.$res->user_id)?>
in the view and then, in the controller you ask for user_id
$this->input->get('user_id');
Do you see the difference? You set a query item id=
but ask for (get) query item user_id
. So you need to change the code so they match. This is probably why nothing has been getting deleted. You haven't been getting the id value.
You might consider simply passing the id
in the URI like this
<?= site_url('userController/delete/'.$res->user_id)?>
And then the controller function is changed to this
public function delete($id)
{
$this->load->database();
$this->load->model('userdetailModel');
$this->userdetailModel->deleteOne($id);
$data['results'] = $this->userdetailModel->viewAll();
$this->load->view('userView', $data);
}
Note how $id
is now an argument to the function and can more easily be used.
In the deleteOne
function of the model, you have mixed up some tasks. The functions select
and from
are not used when deleting from a table.
It's a good idea to have model functions return something so the controller knows if everything worked or not.
function deleteOne($id)
{
if(empty($id))
{
return false; //oops, no data for 'where' to use
}
$result = $this->db
->where('user_id', $id)
->delete('user_details');
return $result !== false;
}
Notice we're checking incoming data item $id
. No point in running a query if there is no data the where()
can use. If $id
is empty then return false.
The function delete()
will return either an object (of type CI_DB_query_builder
) or the boolean FALSE. So the last line of code above will evaluate to a boolean, either TRUE if $result
is not false, or FALSE if it is.
By testing the model return value you can send a message to your view if there is a problem, or if the delete succeeded - whatever you think best. I'll leave using the model return in the controller to you. Hope this helps.
answered Nov 27 '18 at 16:48
DFriendDFriend
7,0071521
7,0071521
add a comment |
add a comment |
try this query in model:
function deleteOne($id){
return $this->db->where('user_id',$id)->delete('table_name');
}
add a comment |
try this query in model:
function deleteOne($id){
return $this->db->where('user_id',$id)->delete('table_name');
}
add a comment |
try this query in model:
function deleteOne($id){
return $this->db->where('user_id',$id)->delete('table_name');
}
try this query in model:
function deleteOne($id){
return $this->db->where('user_id',$id)->delete('table_name');
}
answered Nov 28 '18 at 4:23
PHP GeekPHP Geek
1,3861718
1,3861718
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%2f53503122%2fcodeigniter-delete-query-doesnt-delete-row%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
'id='.$res->user_id' . 'id' its your param name . But in controller you check 'user_id'
– Yaroslaw
Nov 27 '18 at 15:43
Please edit the question and include code for
userdetailMode
deleteOne()
andviewAll()
– DFriend
Nov 27 '18 at 15:44
user_id is the field name on my sql database. Im trying to delete a row from the database. After deleting, the table being displayed should refresh and shows the current database (without the deleted row).
– lolo mo
Nov 27 '18 at 15:48
@DFriend i have edited my question and the codes
– lolo mo
Nov 27 '18 at 15:57