• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Table

#1
[eluser]davy_yg[/eluser]

Hello all,

I am trying to create table. Here is the code that I type:

controllers/tables.php

Code:
<?php

class Tables extends CI_Controller {

public function create_table()
{

$this->load->library('table');

$this->table->set_heading(array('Name', 'Color', 'Size'));

$this->table->add_row(array('Fred', 'Blue', 'Small'));
$this->table->add_row(array('Mary', 'Red', 'Large'));
$this->table->add_row(array('John', 'Green', 'Medium'));

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


}

}

?>


views/table.php

Code:
<html>
<body>

<?php  echo $this->table->generate();  ?>


</body>
</html>

I point my url to:

http://localhost/News/index.php/table/


404 Page Not Found

The page you requested was not found.


Why is it?

#2
[eluser]PravinS[/eluser]
your controller name is "Tables", so you URL should be

http://localhost/News/index.php/tables/

you missed "s"

#3
[eluser]noideawhattotypehere[/eluser]
not only tables, but tables/create_table

@davy, remember, its base_url/[optional, depends on htaccess]index.php/controller/method,
you dont need to call method by name if you want to call method called 'index'.

#4
[eluser]davy_yg[/eluser]
I try : http://localhost/News/index.php/tables/create_table

and http://localhost/News/index.php/tables/

both of them show me this error:


404 Page Not Found

The page you requested was not found.


#5
[eluser]PravinS[/eluser]
is there any view, library, helper which is loaded in your controller but physically missing from that give path

#6
[eluser]davy_yg[/eluser]

views/table.php does exist.

I don't know about the files in libraries & helpers since I unable to view (see) them directly in the folder. They are invisible, I only see the index file.


#7
[eluser]PravinS[/eluser]
paste your "create_table" function code here

#8
[eluser]davy_yg[/eluser]

controllers/tables.php

Code:
<?php

class Tables extends CI_Controller {

public function create_table()
{

$this->load->library('table');

$this->table->set_heading(array('Name', 'Color', 'Size'));

$this->table->add_row(array('Fred', 'Blue', 'Small'));
$this->table->add_row(array('Mary', 'Red', 'Large'));
$this->table->add_row(array('John', 'Green', 'Medium'));

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


}

}

?>

#9
[eluser]PravinS[/eluser]
you have loaded library "table" and view "table", one of them is not present physically, so you are getting "404 Page Not Found" error,


Code:
$this->load->library('table');
$this->load->view('table');


#10
[eluser]davy_yg[/eluser]

I can see these files:

Code:
News/system/libraries/Table.php
News/application/views/table.php


What should I do?


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.