CodeIgniter Forums
How will query string be formatted - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: How will query string be formatted (/showthread.php?tid=49942)



How will query string be formatted - El Forum - 03-08-2012

[eluser]bleu[/eluser]
The current url for
Code:
http://localhost/~xyz/index.php?c=controller&m=method&id1=123

is coming as
Code:
http://localhost/~xyz/index.php/controller/method/123/


How will this url come
Code:
http://localhost/~xyz/index.php?c=controller&m=method&id1=a123&id2=b123&id3=c123&id4=f123&id5=e123&id6=f123



How will query string be formatted - El Forum - 03-08-2012

[eluser]animatora[/eluser]
[quote author="bleu" date="1331219864"]The current url for
Code:
http://localhost/~xyz/index.php?c=controller&m=method&id1=123

is coming as
Code:
http://localhost/~xyz/index.php/controller/method/123/


How will this url come
Code:
http://localhost/~xyz/index.php?c=controller&m=method&id1=a123&id2=b123&id3=c123&id4=f123&id5=e123&id6=f123
[/quote]

Code:
http://localhost/~xyz/index.php/controller/method/a123/b123/c123/d123....
in controller you should have:

Code:
public function method($id1, $id2, $id3...)
{
}



How will query string be formatted - El Forum - 03-08-2012

[eluser]bleu[/eluser]
In My controller I want to use it in a fashion as
a condition
Code:
if($_GET["id5"]=="f123"){ }




How will query string be formatted - El Forum - 03-08-2012

[eluser]animatora[/eluser]
[quote author="bleu" date="1331220958"]In My controller I want to use it in a fashion as
a condition
Code:
if($_GET["id5"]=="f123"){ }

[/quote]


Controller

Code:
public function my_method($id1, $id2, $id3)
{
   if($id1 == "string")
    // Some code here
}



How will query string be formatted - El Forum - 03-08-2012

[eluser]bleu[/eluser]
[quote author="animatora" date="1331221744"][quote author="bleu" date="1331220958"]In My controller I want to use it in a fashion as
a condition
Code:
if($_GET["id5"]=="f123"){ }

[/quote]


Controller

Code:
public function my_method($id1, $id2, $id3)
{
   if($id1 == "string")
    // Some code here
}
[/quote]


Thanks but what if I want to use it in another method and I cannot send $id1 from my_method to that other method , I believe I will have to get it from the url.

How will I do that?


How will query string be formatted - El Forum - 03-08-2012

[eluser]animatora[/eluser]
Get it from URL like:
Code:
$this->uri->segment(3);// Will get 11 from example.com/class/method/11

Check the URL class for more examples
http://ellislab.com/codeigniter/user-guide/libraries/uri.html