Welcome Guest, Not a member yet? Register   Sign In
how to send a value in the parameter without using the parameter name in the url?
#1

[eluser]vindhyareddy[/eluser]
I am following the following tutorial.
http://net.tutsplus.com/tutorials/php/wo...igniter-2/

../index.php/example_api/users is the way how a url is being called.

Consider a url :

../index.php/example_api/user_type/fulltime/userid/12

This give the user details of the user bearing id 12 and a fulltime student.

Second e.g. :
../index.php/example_api/fulltime/userid/12

How do I create this url? Like as in this url user_type(parameter name) has not been used.Directly a value has been used.
#2

[eluser]Dunrobin[/eluser]
Your URL should be in the form of ../index.php/controller_name/function_name/value/

for example, index.php/students/view/12

which would call a view() function in a students.php controller, with the userid in the third position. You can retrieve that value using $userid = $this->uri->segment(3, 'default value'). See the URI Class page in the user guide for more info.

http://ellislab.com/codeigniter/user-gui...s/uri.html

UPDATE: I should have mentioned that there is a way to pass along an associative array of key/value pairs in your URL, similar to what you had in your example, using the URI Class. I haven't used those functions so far, so I didn't think of them at first. You can find info on the $this->uri->uri_to_assoc(n) and $this->uri->assoc_to_uri() functions on the same page referenced above.
#3

[eluser]vindhyareddy[/eluser]
Wow thats awesome!

Thanks a bunch for the reply.

In the url, how do i remove the index.php? Is it mandatory that it must be there?
#4

[eluser]Dunrobin[/eluser]
[quote author="vindhyareddy" date="1279580619"]Wow thats awesome!

Thanks a bunch for the reply.

In the url, how do i remove the index.php? Is it mandatory that it must be there?[/quote]

I know that you can do that (through the .htaccess file, IIRC), but I haven't done that yet, so I can't really help you there. If I find a good explanation on how to do it I'll post a link here. I'm sure someone has already explained how to do it somewhere in the forum. ;-)
#5

[eluser]Dunrobin[/eluser]
How quick is this for a response? Here's a thread with the code to put into a .htaccess file on your server that will let you strip the index.php out of your URLs:

http://ellislab.com/forums/viewthread/155801/




Theme © iAndrew 2016 - Forum software by © MyBB