php


Using segments and and URI for Get variables using Codeigniter [on hold]


Okay,
So I am looking to do something similar to index.php/show?p=1, however I know that using GET is disabled in Codeigniter by default. So I was wondering how I would set this up in a controller using URI and Segments, so it would look like index.php/show/1. Or is this not possible?
Obviously the '1' will be changed based on a value in the database.
I hope this makes sense, if not, please let me know.
$_GET is not disabled by default.
Doing the URI segments thing is as easy as adding a single route, and this is covered by the tutorial in the official documentation.
To have the URL http://example.com/index.php/show/1 do as you ask you would modify the file application/config/routes.php to accomplish the task.
Assuming show is a controller and you want the index() method of the controller to handle the above URL you need to do a couple things.
Define the index method to accept an argument
public function index($arg)
{
...
Add the following to application/config/routes.php
$route['show/(:any)'] = 'show/index/$1';
If you want to use some method other than index() to handle the chore - let's say doShow() then the route looks like this.
$route['show/(:any)'] = 'show/doShow/$1';
And the method is
public function doShow($arg)
{
...
No matter what method used - index() or doShow() - if you don't pass an argument in the second URI segment you will get a 404 - Page Not Found screen.

Related Links

PayPal IPN simuator not working?
i am confused what file extension should i use
PHP Implement a Down for Maintenance Page
How to disable JIT compilation with HHVM?
3 results of MySQL data in each row using PHP and twitter bootstrap
Get only image url from phpbb post text
why mysql conver bool into tinyint(1) instead it should be bool into mysql table [duplicate]
Redirect wrong urls to 404 page
Get template for ASP.NET? Get content of another code?
Disable Cash on Delivery for specific products
How to display magento product categories in column wise
how can i pass variable to php after open modal
getting index of outer array if there's a match in inner array
Make a list of Items from steam Marketplace
How to display default image if particular image is not available in database?
Is PSR-4 just for small package?

Categories

HOME
nam
freeradius
add-on
devexpress
stacktrace.js
adobe
mirc
cypher
openflow
implicit-conversion
linker
impala
telegraf
responsive-design
specifications
async-await
pinterest
cloudsim
infrared
sipp
mod-wsgi
jackrabbit-oak
iwebbrowser2
microprocessors
google-play-developer-api
fotorama
nsuserdefaults
ms-dos
eclipse-gmf
mv
linq.js
rdp
access-denied
nuclio
ol3-google-maps
iptv
mura
wikimapia
word-2016
thread-exceptions
openquery
data-management
system.net.mail
msbuild-4.0
yii2-model
noclassdeffounderror
gridbaglayout
okta-api
openmrs
management-studio-express
arbre
chicagoboss
libz
darwin
bootstrap-wysiwyg
com0com
mutators
password-recovery
flurry-analytics
wicket-1.5
smacss
.htpasswd
webaii
pre
nosql-aggregation
mft
sensormanager
ctp
progress-db
application-server
insertonsubmit
zend-pdf
android-dialog
instance-variables
getopt-long
kolite
space-partitioning
startupscript
upshot
css-friendly
formal-semantics
hungarian-notation
ccnet-config
odac
oracle-pro-c
subtext
tacit-programming
accumulator
version-control-migration
jvm-bytecode
webclient.uploaddata
parentid

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile