Welcome Guest, Not a member yet? Register   Sign In
How to call another controller?
#8

[eluser]Near[/eluser]
yes im using anchor tags and my $config['base_url'] are set to "http://localhost/Oceano";

heres my code
_________________________________

TIDES CONTROLLER

<?php

Class Tides_Controller extends CI_Controller {

function __construct()
{

parent::__construct();

$this->load->model('tides_model');
$this->load->helper('form');
$this->load->helper('html');

}

function Index()
{

$this->load->view('Index');

}


//get the list of distinc stations in the database
function getStation()

{

$data['query1'] = $this->tides_model->getStation();
$this->load->view('main',$data);

}

function hourlyQuery()
{

$this->load->view('hourlyHeights');

}

function hourlyMonth()
{

$month = $_POST['month'];
$year = $_POST['year'];
$datum = $_POST['datum'];
$hidden = $_POST['hidden'];
$key = $_POST['key'];

$date = $year."-".$month;

$data2['query2'] = $this->tides_model->getMonthly($date,$datum,$hidden);

$data2['key'] = $key;
$data2['datum'] = $datum;

$this->load->view('/viewers/hourly_viewer',$data2);

}


}

?>

__________________________________________

TIDES_MODEL

class Tides_model extends CI_Model {

function Events_model(){
parent::__construct();
}

function getStation(){

$query1 = $this->db->query('SELECT DISTINCT location FROM proc_tides');

return $query1;

}

function getMonthly($date,$datum,$hidden){

$query2 = $this->db->query("SELECT height FROM proc_tides where date_p like '$date%' and location='$hidden'");
return $query2;

}

function getHourlyYear($date,$location,$datum){
$query4 = $this->db->query("SELECT height FROM proc_tides where date_p like'$date%' and location ='$location'");
return $query4;

}

}
_____________________________________


INDEX (VIEW)

<?php echo anchor('tides_controller/getStation','Query Center')?>

<br />
<br />

&lt;?php echo anchor('tides_controller/call_database_main','Database'); ?&gt;

&lt;/body&gt;
&lt;/html&gt;
__________________________________

MAIN (VIEW)

&lt;html&gt;
&lt;form action="category_view" method="post"&gt;
<select name="station">

&lt;?php
foreach ($query1->result() as $row)
{
?&gt;

<option>&lt;?php echo $row->location; ?&gt;</option>

&lt;?php
}
?&gt;
</select>
&lt;input type="submit" name="submit" value="SUBMIT"&gt;
&lt;/form&gt;
&lt;/html&gt;
_______________________

CATEGORY_VIEW

&lt;?php
echo anchor('tides_controller/hourlyQuery/'.$station,'HOURLY HEIGHTS');
?&gt;

&lt;?php
echo anchor('highlow_controller/test/' .$station, 'HIGH AND LOW TIDES');
?&gt;

_____________________________

HOURLY_HEIGHTS (VIEW)

&lt;?php $station = $this->uri->segment(3)?&gt;
&lt;?php echo 'Enter your Query for'.' '.$station?&gt;

&lt;html&gt;
<h1>Monthly Query</h1>

&lt;form action="hourlyMonth" method="post"&gt;

<label for="year">Enter Year</label>
&lt;input type="text" name="year"&gt;

<label for="month">Enter month</label>
&lt;input type="text" name="month"&gt;&lt;br><br>

<label for="datum">Datum</label>
&lt;input type="text" name="datum" value="0"&gt;&lt;br>

&lt;input type="submit" value="Submit Query"&gt;
&lt;input type="hidden" name="hidden" value="&lt;?php echo $station;?&gt;"&gt;
&lt;input type="hidden" name="key" value="1"&gt;


&lt;/form&gt;


my problem is when i click the submit button at hourly_Heights the page is loaded in the same page?


Messages In This Thread
How to call another controller? - by El Forum - 07-13-2011, 10:18 PM
How to call another controller? - by El Forum - 07-13-2011, 10:39 PM
How to call another controller? - by El Forum - 07-13-2011, 11:18 PM
How to call another controller? - by El Forum - 07-13-2011, 11:20 PM
How to call another controller? - by El Forum - 07-13-2011, 11:34 PM
How to call another controller? - by El Forum - 07-14-2011, 02:00 AM
How to call another controller? - by El Forum - 07-14-2011, 02:38 AM
How to call another controller? - by El Forum - 07-14-2011, 04:30 AM
How to call another controller? - by El Forum - 07-14-2011, 04:53 AM
How to call another controller? - by El Forum - 07-14-2011, 05:01 AM
How to call another controller? - by El Forum - 07-14-2011, 05:03 AM



Theme © iAndrew 2016 - Forum software by © MyBB