Welcome Guest, Not a member yet? Register   Sign In
URI String Question
#1

On one of my controllers I have a query string set in my site url. It works fine

PHP Code:
site_url('admin/catalog/category/edit?&category_id=' $result['category_id']) 

Out put http://localhost/project/admin/catalog/c...gory_id=95

And when I echo $this->input->get('category_id') it echos the correct number.

The question is if I remove the ? question mark from url it will not work. Is there away to use it with out question mark. I just would like the & to be the start.
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply
#2

(This post was last modified: 04-17-2015, 10:03 AM by pompeu.)

Hello riwakawd ,

look at the documentation on routes , I think that will solve your problem Smile

https://ellislab.com/codeigniter/user-gu...uting.html


Example http://localhost/project/admin/catalog/c...gory_id=95

$route['project/admin/catalog/category/edit?&category_id=:num'] = 'project/admin/catalog/category/'

result: http://localhost/project/admin/catalog/category/95

It would be something like this ^^
good luck
Reply
#3

(04-17-2015, 09:53 AM)pompeu Wrote: Hello riwakawd ,

look at the documentation on routes , I think that will solve your problem Smile

https://ellislab.com/codeigniter/user-gu...uting.html


Example http://localhost/project/admin/catalog/c...gory_id=95

$route['project/admin/catalog/category/edit?&category_id=:num'] = 'project/admin/catalog/category/'

result: http://localhost/project/admin/catalog/category/95

It would be something like this ^^
good luck

Wrong user guide link http://www.codeigniter.com/userguide2/

But sorry not what I am after I know all that.
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply
#4

Assuming that edit is a method inside your controller, change the URL to
site_url('admin/catalog/category/edit/' . $result['category_id'])

and your edit function signature to function edit($category_id)

and you then won't need the input method at all Smile
Reply
#5

(This post was last modified: 04-17-2015, 11:36 PM by wolfgang1983.)

(04-17-2015, 09:58 PM)ciadmin Wrote: Assuming that edit is a method inside your controller, change the URL to
site_url('admin/catalog/category/edit/' . $result['category_id'])

and your edit function signature to function edit($category_id)

and you then won't need the input method at all Smile

Hi Thanks for the reply the reason why now deiced to use input gets is because in some cases the uri segments have my string show wrong.

I still use uri segments in some areas.

I think i am just going to have to include the question mark before the & from now and not worry about it.
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply
#6

No, you can't do it without the question mark, and this has nothing to do with CodeIgniter - it's how HTTP works. In fact, '?&' is also wrong - you can think of the question mark as your first usage of '&', if that's easier for you.

You also might find this function helpful: http://php.net/http_build_query
Reply
#7

(This post was last modified: 04-18-2015, 09:07 PM by wolfgang1983.)

(04-18-2015, 12:32 PM)Narf Wrote: No, you can't do it without the question mark, and this has nothing to do with CodeIgniter - it's how HTTP works. In fact, '?&' is also wrong - you can think of the question mark as your first usage of '&', if that's easier for you.

You also might find this function helpful: http://php.net/http_build_query

When you mean as your first usage

http://localhost/project/?admin/user/use...user_id=20

Some thing like that?
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply
#8

No, like this:

http://localhost/project/admin/user/user...user_id=20
Reply
#9

@riwakawd

http://en.wikipedia.org/wiki/Uniform_resource_locator

"The syntax is:
scheme://[user:password@]domain:port/path?query_string#fragment_id"

and below

"The query string contains data to be passed to software running on the server. It may contain name/value pairs separated by ampersands, for example

?first_name=John&last_name=Doe"

You cannot replace the question mark, otherwise your URL will not be valid.
Reply
#10

(04-19-2015, 03:31 AM)Narf Wrote: No, like this:

http://localhost/project/admin/user/user...user_id=20

OK Cheers

I do it that way now just have to remember to always put question mark like that now.
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply




Theme © iAndrew 2016 - Forum software by © MyBB