Mark Daryl Senju Uchiiha February 2016

Use modal bootstrap as delete prompt in codeigniter?

I have a problem about to view or prompt a delete text confirmation, can I use the modal in bootstrap in prompt as a delete?

I try and it can delete but in the first "id" only not in specific id and I don't know what to do to make specific id.

here is my view:

<div class="table-responsive">
                    <?php if(sizeof($query) < 1) : ?>
                    No record in the database.
                    <?php else : ?>
                    
                    <table class="table table-hover">
                        <thead>
                            <tr>
                                <th>ID</th>
                                <th>TITLE</th>
                                <th>CONTENT</th>
                                <th>LAST UPDATE</th>
                                <th>ACTIONS</th>
                               
                            </tr>
                        </thead>
                        <tbody>
                            <?php foreach($query as $record) : ?>
                            <tr>
                                <td><?php echo $record->Id; ?></td>
                                <td><?php echo word_limiter($record->Title, 5); ?></td>
                                <td><?php echo word_limiter($record->Paragraph, 15); ?></td>
                                <td><?php echo $record->Lastupdate; ?></td>
                                <td>
                                    <div class="btn-group btn-group-sm">
                                        <a href="<?php echo base_url('gallery/view').'/'        

Answers


msvairam February 2016

Try this coding ..

I have dynamically Generate the Model popup

<div class="table-responsive">
                    <?php if(sizeof($query) < 1) : ?>
                    No record in the database.
                    <?php else : ?>

                    <table class="table table-hover">
                        <thead>
                            <tr>
                                <th>ID</th>
                                <th>TITLE</th>
                                <th>CONTENT</th>
                                <th>LAST UPDATE</th>
                                <th>ACTIONS</th>

                            </tr>
                        </thead>
                        <tbody>
                            <?php foreach($query as $record) : ?>
                            <tr>
                                <td><?php echo $record->Id; ?></td>
                                <td><?php echo word_limiter($record->Title, 5); ?></td>
                                <td><?php echo word_limiter($record->Paragraph, 15); ?></td>
                                <td><?php echo $record->Lastupdate; ?></td>
                                <td>
                                    <div class="btn-group btn-group-sm">
                                        <a href="<?php echo base_url('gallery/view').'/'.$record->Id; ?>" class="btn btn-info">View</a>
                                        <a href="#" class="btn btn-success">Edit</a>
                                        <a href=""  class="btn btn-danger" data-toggle="modal" data-target="#myModal<?php echo $record->Id; ?>">Delete</a>
                                    </div>    
                                </t 


Praveen Kumar February 2016

Use this code you do not need to add dynamic modal each time in your view :)

    
        <div class="table-responsive">
                            <?php if(sizeof($query) < 1) : ?>
                            No record in the database.
                            <?php else : ?>
                            
                            <table class="table table-hover">
                                <thead>
                                    <tr>
                                        <th>ID</th>
                                        <th>TITLE</th>
                                        <th>CONTENT</th>
                                        <th>LAST UPDATE</th>
                                        <th>ACTIONS</th>
                                       
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php foreach($query as $record) : ?>
                                    <tr>
                                        <td><?php echo $record->Id; ?></td>
                                        <td><?php echo word_limiter($record->Title, 5); ?></td>
                                        <td><?php echo word_limiter($record->Paragraph, 15); ?></td>
                                        <td><?php echo $record->Lastupdate; ?></td>
                                        <td>
                                            <div class="btn-group btn-group-sm">
                                                <a href="<?php echo base_url('gall 

Post Status

Asked in February 2016
Viewed 3,454 times
Voted 7
Answered 2 times

Search




Leave an answer