⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

noob questions



edlentz
  • profile picture
  • Member

Posted 26 February 2021 - 15:15 PM

I am new to grocery crud and it looks like it is perfect for what I want to do.  I have a mysql DB with one table that has about 8 fields.  I have edited the config.php file for the baseurl, i have edited the database.php file for the connection to the DB.  I created a new controller file called Main.php with the following:

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

 
class Examples extends CI_Controller {
 
    function __construct() {
        parent::__construct();

 
        /* Standard Codeigniter Libraries */
        $this->load->database();
        $this->load->helper('url'); 
 
        $this->load->library('grocery_CRUD');    
    }
 
    function my_boss_is_in_a_hurry() {
    $crud = new grocery_CRUD();
    $crud->set_table('info');
    $crud->columns('id,'dealerid','dealername','contact','phone','email','level','credit');
 
    $output = $crud->render();
 
    $this->output($output);
}
}

When I access the Main.php I get this error:

A PHP Error was encountered

Severity: Parsing Error

Message: syntax error, unexpected 'dealerid' (T_STRING)

Filename: controllers/Main.php

Line Number: 20

Backtrace:

 

I don't understand what I have wrong.  Help please

 


edlentz
  • profile picture
  • Member

Posted 02 March 2021 - 16:12 PM

So I figured out the syntax error, now I am getting a 404 page not found error.  Here is my corrected Main.php file

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

 
class Main extends CI_Controller {
 
    function __construct() {
        parent::__construct();

 
        /* Standard Codeigniter Libraries */
        $this->load->database();
        $this->load->helper('url'); 
 
        $this->load->library('grocery_CRUD');    
    }
 
    function my_first_crud() {
    $crud = new grocery_CRUD();
    $crud->set_table('info');
    $crud->columns('id','dealerid','dealername','contact','phone','email','level','credit');
 
    $output = $crud->render();
 
    }
}

I know there is a turotial on the website, but for me it isn't basic enough.  I added the base URL to the config.php, filled in the DB info in database.php and added the Main.php file above to the controller directory.  What else could I be missing?  Thanks


edlentz
  • profile picture
  • Member

Posted 05 March 2021 - 18:56 PM

Many thanks to the many people helping out.  I really appreciate it.


cybersven
  • profile picture
  • Member

Posted 16 March 2021 - 17:22 PM

Seriously ?

What about the return... it's basic :

$this->_example_output($output);
function my_boss_is_in_a_hurry() {
    $crud = new grocery_CRUD();
    $crud->set_table('customers');
    $crud->columns('customerName','phone','addressLine1','creditLimit');
 
    $output = $crud->render();
 
    $this->_example_output($output);
}