codeigniter

how to split a data from database based on character

Hi I have a data april/2010 to jan/2011 Is there any way to split the data with character to and select the date as The value before "to" as FROM and The Value after "to" as TO how to selet the splited value......... while i am selecting the data as it is as select date from mytbl how to select the date as two values ...

Counting the most tagged tag with MySQL

Hi folks My problem is that I'm trying to count which tag has been used most in a table of user-submitted code. But the problem is with the database structure. The current query I'm using is this: SELECT tag1, COUNT(tag1) AS counttag FROM code GROUP BY tag1 ORDER BY counttag DESC LIMIT 1 This is fine, except, it only counts the ...

Call to a member function num_rows() on a non-object

I need to get the number of rows of a query (so I can paginate results). As I'm learning codeigniter (and OO php) I wanted to try and chain a ->num_rows() to the query, but it doesn't work: //this works: $data['count'] = count($this->events->findEvents($data['date'], $data['keyword'])); //the following doesn't work and generates // Fa...

if statement inside array : codeigniter

Hello , I have this function to edit all fields that come from the form and its works fine .. function editRow($tableName,$id) { $fieldsData = $this->db->field_data($tableName); $data = array(); foreach ($fieldsData as $key => $field) { $data[ $field->name ] = $this->input->post($field->name); } $this...

MVC best practice

I'm new to MVC (i'm using codeigniter) and was wondering where I should put a "cut_description" function. My model retrieves a list of events including their description. If the description is too long, I would need to cut it after the first n words, and add a "read more" link, so the view doesn't get too cluttered. What would be the b...

HTML codes showing in viewpage HTML data

Hello Guys, I’m a new to Codeigniter. Just using it in my project from last 2 months. I’ve a comment section in my project. Where any one can give comments. Every things are going perfect but when ever any one putting HTML content(image/videos) & then when those are showing back in the comment section… direct HTML codes are showing in th...

How should I manage my many-to-many relationships?

Hello all, I have a database containing a couple tables: files and users. This relationship is many-to-many, so I also have a table called users_files_ref which holds foreign keys to both of the above tables. Here's the schema of each table: files -> file_id, file_name users -> user_id, user_name users_file...

Display PDF file in modal window

Is there any way I can direct display PDF files in modal boxes? I am using CodeIgniter PHP framework and jQuery as JavaScript framework. UPDATE: I read on net that this is possible by loading it in iframe, and Adobe PDF will render it, but many seems to oppose, so is there any way I can convert those PDFs to images? ...

Taking wrong database configuration array

Hi, I have one application in which i have used 2 database connections. In my database config file i have given two arrays as below. $active_group = ‘default’; $active_record = TRUE; FIRST ARRAY $db[‘default’][‘hostname’] = ‘hostname’; .............. .......... SECOND ARRAY $db[‘another_db’][‘hostname’] = ‘hostname’; .............. ....

How to call a php controller method using jquery?

I am developing a web application and i am integrating jquery in it... Now looking for ajax calls with jquery to my controller function.... jquery.ajax() would be useful i think so... But how to call my controller method.... $.ajax({ type: "POST", url: "http://localhost/codeigniter_cup_myth_new/index.php/libraryControll...

PHP - CodeIgniter

I try to write a site with CodeIgniter but I've a problem with PHP. I'm sure that it's so simple and can't be wrong. But I don't know bugs from , just a newbie of CodeIgniter :) <html> <head> <title><?=$page_title?></title> </head> <body> <?php foreach($result as $row):?> <h3><? echo $...

codeigniter - Page with multiple forms

Hi, I'm new to codeigniter this is my case: I have a homepage with a list of items, I can navigate through pagination, but I have in my sidebar a login form, it's possible to return to the same page after try to login in the case that is valid or not with a validation message. for the login option I have a controller and login function b...

Is this a valid url parameter in jquery.ajax()?

Is this a valid url parameter in jquery.ajax(), <script type="text/javascript"> $(document).ready(function() { getRecordspage(); }); function getRecordspage() { $.ajax({ type: "POST", url: "http://localhost/codeigniter_cup_myth/index.php/adminController/mainAccount", data: "", contentType:...

Jquery ajax success function returns null?

I use the following the jquery statements to call my php controller function, it gets called but my result is not returned to my success function.... <html> <head> <link rel="stylesheet" type="text/css" href="http://localhost/codeigniter_cup_myth/stylesheets/style.css" /> <link rel="stylesheet" type="text/css" href="http://localhost...

Getting started with URL routing with PHP CodeIgniter

I just thought of routing my URLs which is like http://localhost/codeigniter_cup_myth/index.php/adminController/mainAccount and it would be pretty nice if it was http://localhost/codeigniter_cup_myth/Accounts/mainAccount Where should I start when routing URLs in my web application? ...

Is it possible to return multiple variables/arrays in Codeigniter?

Let's say in my model, I have a function that queries two separate tables. I need to pass the results back to my controller to display in my view. I'm using MongoDB but it should be the same for any other DB. Normally this would work. $files = $grid->find(array("username" => $profile_id, "thumbnail" => array('$ne'...

Problem with ajax form on Codeigniter

Everytime I test the email is send correctly. (I have tested in PC: IE6, IE7, IE8, Safari, Firefox, Chrome. MAC: Safari, Firefox, Chrome.) Nome: Jon Doe Empresa: Star Cargo: Developer Email: [email protected] Telefone: 090909222988 Assunto: Subject here.. But I keep recieving emails like this from costumers: Nome: Empresa: Cargo: Em...

Default Contoller in CodeIgniter

I am wondering if there is any other configuration options for a default controller. For example - if I have a controller called "site" and I set the default controller in the following file: application/config/routes.php to: $route['default_controller'] = "site"; I should be able to go to http://localhost and that brings up the ind...

Load a model in a Codeigniter library

Hello, people! I have this piece of code: class MY_Language extends CI_Language { function MY_Language() { parent::CI_Language(); $CI =& get_instance(); $CI->load->model('language_model'); $languages = $this->language_model->get_languages(); print_r($languages); } } But I keep...

Codeigniter: How to handle direct link to controller/function/param?

I have a simple controller function which deletes a DB entry (it uses a model function to do so). I have a link to this in one of my views (e.g. http://www.example.com/item/delete/3) and I’m using jQuery to display a confirm dialog to make sure the user really wants to delete it. All fine. However if you just enter that URL in your brows...