codeigniter

How to pass parameter after baseurl in codeigniter?

て烟熏妆下的殇ゞ 提交于 2020-01-16 18:10:51
问题 Base URL: http://localhost/f1/ and I am passing parameter in URL like: http://localhost/f1/user1 and I am trying to print function index(){ echo $this->uri->segment(2); } I want to print User1 in the controller. How to achieve this? 回答1: Config your rout and add this: $route['Controller_Name/(:any)'] = 'Controller_Name/index/$1'; Here you go with your controller class Controller_Name extends CI_Controller { function index($prm){ echo $prm; } } Have fun.... you can have how many uri you want..

How to pass parameter after baseurl in codeigniter?

和自甴很熟 提交于 2020-01-16 18:09:08
问题 Base URL: http://localhost/f1/ and I am passing parameter in URL like: http://localhost/f1/user1 and I am trying to print function index(){ echo $this->uri->segment(2); } I want to print User1 in the controller. How to achieve this? 回答1: Config your rout and add this: $route['Controller_Name/(:any)'] = 'Controller_Name/index/$1'; Here you go with your controller class Controller_Name extends CI_Controller { function index($prm){ echo $prm; } } Have fun.... you can have how many uri you want..

CodeIgniter syntax

做~自己de王妃 提交于 2020-01-16 17:35:28
问题 Merged with CodeIgniter problem retrieving and displaying data from DB. Here is my code: $this->load->model('login/configurations', '', TRUE); $data['query'] = $this->configurations->load_data(); But my query is not being loaded here: $data['title'] = 'User Area'; $data['main_content'] = 'resources/logged_in_area'; $this->load->view('templates/resources_area', $data); I think it may have to do with the path of my model. "Login" is the name of the folder "configurations" is in. The title and

codeigniter pass data from view to model and retrieve info

醉酒当歌 提交于 2020-01-16 16:24:24
问题 Here is the thing: I have controller that retrieve data from database and pass info to view. In the view I have a loop like this: foreach ($myphotos->result() as $myphoto){ echo $myphoto->p_id } But in that loop I need to pick up $myphoto->p_id and ask database to retrieve me users with this p_id. SELECT * FROM users WHERE u_id IN (SELECT u_id FROM p_votes WHERE p_id = 268); and in: foreach ($myphotos->result() as $myphoto){ echo $myphoto->p_id $this->load->model('m_member'); $users_voted =

Creating a 14 character 'random key generator'

安稳与你 提交于 2020-01-16 13:19:08
问题 I'm trying to use CodeIgniter to write up a small program for school which generates a random 'key' every time I click the 'generate' button. Looking to see if there's a way for me to create a function where I can fill up a 14 character array with a random number or letter and then set the array to a variable which I can call upon to display as my generated key. Any and all help would be much appreciated as I am new to CodeIgniter. 回答1: A while back I wrote this function in PHP, it does what

URL redirect using .htaccess

纵然是瞬间 提交于 2020-01-16 09:36:13
问题 I have changed my normal™ php website to CodeIgniter framework. My issue is I need to: redirect http://samajam.org/contact_us.php to http://samajam.org/contact 回答1: Try Redirect 301 /contact_us.php http://samajam.org/contact Enjoy, i hope i helped you :) 回答2: You can set 301 redirection in your .htaccess file like - Redirect 301 http://samajam.org/contact_us.php http://samajam.org/contact OR you can use CodeIgniter URL Helper for redirection 来源: https://stackoverflow.com/questions/49505791

URL redirect using .htaccess

青春壹個敷衍的年華 提交于 2020-01-16 09:36:07
问题 I have changed my normal™ php website to CodeIgniter framework. My issue is I need to: redirect http://samajam.org/contact_us.php to http://samajam.org/contact 回答1: Try Redirect 301 /contact_us.php http://samajam.org/contact Enjoy, i hope i helped you :) 回答2: You can set 301 redirection in your .htaccess file like - Redirect 301 http://samajam.org/contact_us.php http://samajam.org/contact OR you can use CodeIgniter URL Helper for redirection 来源: https://stackoverflow.com/questions/49505791

codeigniter upload image with other data

二次信任 提交于 2020-01-16 05:46:55
问题 I have a form am submitting and user has the ability to upload a picture in that form then submit the form as whole. I found a tutorial on codeigniter site showing upload form (dedicated only to upload, not other data along). link is: Codeigniter Upload Tutorial. How can I submit the form and then upload the files while also uploading other details to other table in database? 回答1: Below is an example function add_staff(){ $this->load->library('form_validation'); $this->load->helper(array(

PHP prevent foreach loop from overwriting object

Deadly 提交于 2020-01-16 04:23:05
问题 This is the fourth time I've tried writing this question, so please bear with me. I have a PHP object that comes from a DB Query which pulls back the following data: [1] => stdClass Object ( [eventId] => 11 [eventName] => Second Event [...] [eventChildren] => Array ( [0] => stdClass Object ( [childId] => 8 [childName] => Jane Doe [...] [gifts] => Array ( [0] => stdClass Object ( [giftId] => 73 [giftName] => My two front teeth [childId] => 8 [userId] => 1 [eventId] => 11 ) [1] => stdClass

Sorting multiple types of numbers and characters

你离开我真会死。 提交于 2020-01-16 04:00:28
问题 How to sort a table with different numbers and characters. Column in my table is res_no ------ B14 A6 C16 105 FF 114A 113 37 39A 91G 93 93(2) A143B A141 D154a A141(25) C40FF D153(1) E18A D154 A51A A50 E18A1 I want to sort this like res_no ------ 37 39A 91G 93 93(2) 105FF 113 114A A6 A50 A51A A141 A141(25) A143B B14 C40FF D153(1) D154 D154A E18A E18A1 I tried to ORDER BY : REGEXP ('^[0-9]') CAST(res_no AS UNSIGNED) REGEXP_SUBSTR(res_no, '(^[a-zA-Z]+)|([a-zA-Z]$)') CAST(REGEXP_SUBSTR(res_no, '(