codeigniter

codeigniter - dependent dropdown with jquery and ajax post

断了今生、忘了曾经 提交于 2020-01-11 03:07:07
问题 view : learning_view.php Here is the first dropdown which I am populating from database. <select name = 'category' id = 'category'> <option value="">-- Select Category --</option> <?php foreach($category as $item){ ?> <option value="<?php echo $item->id_cat; ?>"><?php echo $item->name; ?></option> <?php } ?> </select> <br><br> What I want is to populate another dropdown which is dependent on the first dropdown. For that I have used the jQuery ajax post. second dropdown: <select name = 'type'

SQL join results into an object in codeigniter

感情迁移 提交于 2020-01-11 02:32:06
问题 ok, a bit of background, just into codeigniter not a fan of sql and server-side scripts i know what joins are i have a many-to-many database for the first time it's because joins typically have the following example as a result. but i wanted to parse this without having to build code to ignore repetitions. it's a 3-table join sample. the issue of repeating values increases as i join more tables: table1.authorid table1.authorname table2.books table3.favorited 1 john john's book 1 jean 1 john

Count rows before adding a further limit statement CodeIgniter?

倾然丶 夕夏残阳落幕 提交于 2020-01-11 02:06:36
问题 I have ran into a problem... I have a bunch of where statments like so... $this->db->where('Pool', "1"); $this->db->where('Bedrooms >=', "3"); Then a limit statement $this->db->limit($limit, $offset); And finally my get statement $query = $this->db->get('table-name'); My problem is I need to count the results before my limit statement, to get the total rows without the limit.. So I tried this.. $this->db->where('Pool', "1"); $this->db->where('Bedrooms >=', "3"); $num_rows = $this->db->count

CodeIgniter global function

╄→尐↘猪︶ㄣ 提交于 2020-01-11 02:04:09
问题 Where can I place my "global" function, which will check, if user is logged in? Because I want to do something like: user is able to browse some pages only when the function isLogged() returns TRUE, and I'd have to use it in some views, that's why it should be a "global" function, which I can access from anywhere. Is that possible? Or there is any better solution for this? 回答1: You should probably put it into a Library, and autoload the library. When you need to use the "logged_in" flag in a

CodeIgniter global function

六月ゝ 毕业季﹏ 提交于 2020-01-11 02:04:08
问题 Where can I place my "global" function, which will check, if user is logged in? Because I want to do something like: user is able to browse some pages only when the function isLogged() returns TRUE, and I'd have to use it in some views, that's why it should be a "global" function, which I can access from anywhere. Is that possible? Or there is any better solution for this? 回答1: You should probably put it into a Library, and autoload the library. When you need to use the "logged_in" flag in a

Moving Codeigniter Project to Amazon EC2, htaccess and ModRewrite Problems

╄→гoц情女王★ 提交于 2020-01-10 20:04:11
问题 I am attempting to move my Codeigniter projects from a shared hosting service to Amazon EC2 and am running into some challenges with my .htaccess settings. These settings enabled me to not have to include index.php in the url. My previous .htaccess is shown below and worked as expected with my previous hosting provider: <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /simple.com/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L]

How to close a jQuery fancybox from button click

大兔子大兔子 提交于 2020-01-10 17:44:11
问题 I'm using fancy box to create a popup and load another page on it using an iframe. here is my code <script type="text/javascript"> $(document).ready(function() { $('.calendar .day').click(function() { day_num = $(this).find('.day_num').html(); day_data = prompt('Enter Stuff', $(this).find('.content').html()); if (day_data != null) { $.ajax({ url: window.location, type: 'POST', data: { day: day_num, data: day_data }, success: function(msg) { location.reload(); } }); } }); }); $(document).ready

Set Session Expiration Time Manually-CodeIgniter

浪子不回头ぞ 提交于 2020-01-10 17:21:09
问题 How can I set session expiration time dynamically in codeigniter? For example, if a user logs in and has the role of admin , the expiration time should be longer than if a user logs in who does not have an admin role. Thanks. 回答1: You can update your session expiration time by increasing this variable in config file: $config['sess_expiration'] = 'somevalue'. Set $config['sess_expiration'] = 0 , if you want it to never expire. Here's a good discussion on CI forums: Dynamically set

Adding header and footer with page number in dompdf

流过昼夜 提交于 2020-01-10 14:29:07
问题 I am working with Codeigniter and I successfully implemented dompdf for generating PDF files. Now I have issues on adding a header and footer in generated PDF. Here is the my dompdf_helper code: <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); function pdf_create($html, $filename='', $stream=TRUE) { require_once("dompdf/dompdf_config.inc.php"); $dompdf = new DOMPDF(); $dompdf->load_html($html); $dompdf->render(); $dompdf->set_paper("A4"); if ($stream) { $dompdf->stream

Check if db->update successful with Codeigniter when potentially no rows are updated

↘锁芯ラ 提交于 2020-01-10 12:04:28
问题 I've been using $this->db->affected_rows() to check if updates have been successful. But this doesn't work when a user inputs the same data to be stored that is already stored (because no column is actually updated). My workaround has been to get the stored data, compare to the inputted data, update if different, return a NO_CHANGE constant if same. With JSON data, there's an extra parsing step. Is there an easier way to check that there was no error with the update? As in, something that