Quantcast
Channel: CodeIgniter Forums - All Forums
Viewing all articles
Browse latest Browse all 14342

passing a string to a view

$
0
0
I have a function in my controller
public function org_chart_management()
{
   $this->load->dbutil();
   $query = $this->db->query("SELECT * FROM employees");
 //echo $this->dbutil->csv_from_result($query);  //write the string
   $string2 = $this->dbutil->csv_from_result($query);  //write the string
   $this->load->view('configure_chart.php',$string2);
  // echo '<script src="/views/configure"></script>';
  // echo $string2;

//    echo '<script type="text/javascript">$string2</script>';

}

And here is the view called configure_chart.php

<!DOCTYPE html>
<html>
<head>
   <title>Substantiator</title>
  <meta charset="utf-8" />
   <meta name="viewport" content="width=device-width, initial-scale=1.0">

   </head>
<body>
<html>
<head>
   <br><br><br><br><br><br>
   <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
   <script type="text/javascript">
       google.charts.load('current', {packages:["orgchart"]});
       google.charts.setOnLoadCallback(drawChart);

       function drawChart() {

           var data = new google.visualization.DataTable();
           data.addColumn('string', 'Name');
           data.addColumn('string', 'Manager');
           data.addColumn('string', 'ToolTip');

           // For each orgchart box, provide the name, manager, and tooltip to show.
           data.addRows([
               [{v:'Mike', f:'Mike<div style="color:red; font-style:italic">President</div>'},
                   '', 'The President'],
               [{v:'Jim', f:'Jim<div style="color:red; font-style:italic">Vice President</div>'},
                   'Mike', 'VP'],
               ['Alice', 'Mike', ''],
               ['Bob', 'Jim', 'Bob Sponge'],
               ['Carol', 'Bob', '']
           ]);

           // Create the chart.
           var chart = new google.visualization.OrgChart(document.getElementById('chart_div'));
           // Draw the chart, setting the allowHtml option to true for the tooltips.
           chart.draw(data, {allowHtml:true});
       }
   </script>
</head>
<body>

</body>


<!--Div that will hold the pie chart-->
<br><br><br>

<body>
<div id="chart_div"></div>
</body>

</body>
</html>


when I run org_chart_management() I get the following screen. This chart that you see if from hard coded sample data. I really want to pass $string2 to configure_chart.php. I tried doing echo $string2 in the controller, but that just prints the $string2 to the view. Can someone tell me how to get the $string2 into the view?

.jpg   Capture.JPG (Size: 46.15 KB / Downloads: 12)

Viewing all articles
Browse latest Browse all 14342

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>