I have created a simple mvc program.
Below is the code for view
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?><!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="<?php echo base_url('assets/css/bootstrap.min.css'); ?>" rel="stylesheet" type="text/css"/>
<link href="<?php echo base_url('assets/css/bootstrap.css'); ?>" rel="stylesheet" type="text/css"/>
</head>
<body>
<div style="margin-left: 5px" class="panel panel-info">
<div style="text-align:left;" class="panel panel-heading">Main
<a id="lnkEditInterests" style="float:right" href="#" data-toggle="modal" data-target="#myModal">
<span class="glyphicon glyphicon-pencil"></span>
</a>
<!-- Modal -->
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Title</h4>
</div>
<div class="modal-body">
<table>
<?php
// this is what causing issue.
$a=$allInterests->num_rows();
?>
<tr>
<td> </td>
</tr>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
<div class="panel panel-body">Panel Content</div>
</div>
<script src="<?php echo base_url('assets/js/bootstrap.js'); ?>" type="text/javascript"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
</body>
</html>
In above view, $allInterests variable is passed from below controller.
Below is the code for Controller
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Profile extends CI_Controller
{
public function main()
{
$this->load->model('Model_Profile');
$data["allInterests"]= $this->Model_Profile->loadAllInterests();
$this->load->view('PROFILE\view_ProfileInterests',$data);
}
}
From controller I am passing $data array which has set of rows.
I need to show this data on modal in table format.
But as soon as I add php code to within table of modal body to display data which is in array, modal stops working, It stops appearing and also Panel Content this div tag disappears.
However a simple echo statement doesnt cause any issue, But if or foreach statements cause issue to Modal.
Is there anything I am missing here? Or Is this not how it is supposed to be?
Can someone please help.
$a=$allInterests->num_rows();outside thetabletag and then using the values within? That may be the problem.