Welcome Guest, Not a member yet? Register   Sign In
passing a string to a view
#1

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?

Attached Files Thumbnail(s)
   
proof that an old dog can learn new tricks
Reply


Messages In This Thread
passing a string to a view - by richb201 - 01-17-2018, 11:12 PM
RE: passing a string to a view - by jreklund - 01-18-2018, 02:09 AM
RE: passing a string to a view - by InsiteFX - 01-18-2018, 04:37 AM
RE: passing a string to a view - by richb201 - 01-18-2018, 09:52 AM
RE: passing a string to a view - by richb201 - 01-18-2018, 12:08 PM
RE: passing a string to a view - by jreklund - 01-18-2018, 12:21 PM
RE: passing a string to a view - by richb201 - 01-18-2018, 02:48 PM
RE: passing a string to a view - by jreklund - 01-18-2018, 03:17 PM
RE: passing a string to a view - by richb201 - 01-18-2018, 03:47 PM
RE: passing a string to a view - by jreklund - 01-19-2018, 12:53 AM
RE: passing a string to a view - by richb201 - 01-19-2018, 01:35 AM
RE: passing a string to a view - by jreklund - 01-19-2018, 04:37 AM
RE: passing a string to a view - by richb201 - 01-26-2018, 11:49 PM
RE: passing a string to a view - by richb201 - 01-28-2018, 09:33 PM



Theme © iAndrew 2016 - Forum software by © MyBB