Codeigniter Retrieve Parameter values passed from View to Controller

Codeigniter Retrieve Parameter values passed from View to Controller

In this Post We Will Explain About is Codeigniter Retrieve Parameter values passed from View to Controller With Example and Demo.Welcome on Pakainfo.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to Codeigniter – How to get url variable value inside contoller function Example

In this post we will show you Best way to implement GET parameters in the URL with CodeIgniter, hear for Codeigniter passing parameters to controller indexwith Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

Also Read :  PHP Download Images From URL Using cURL Example

How to get id from URL in codeigniter

VIEW

<h2>How to get current url with query string in codeigniter</h2>
<?php
echo "<a href='product_delete_controller?cat_id=$cat_id'>";
echo $name;
echo "</a>";
?>

if we have to pass the value we should enter simple url like this

https://pakainfo.com/salon/index.php/products_controller/product_delete_controller/70

Controller

in controller function we can read like this

function product_delete_controller( $cat_id = NULL ) {
  echo $cat_id;
}

Onther Way

echo $this->uri->segment('3');

codeigniter get value from url Example

Your URL using Codeigniter View

recieve the param value in a controller from the simple following URL using codeigniter

https://pakainfo.com/salon/c_service/get_Products/items=123

controller

In Codeigniter we can simply do

public function get_Products($items)
{
   var_dump($items); //will output "items=123"
}

How To Get Last ID From URL In Codeigniter

It permits simple we to retrieve a last ID or segment from the URI using Codeigniter Example. There are the following 3 Example to Retrive Codeigniter Last segment.

Also Read :  C# Calculate Age Tutorial with Examples

Example 1 : codeigniter get url query string

$get_last = end($this->uri->segments); 
//Where here best way to, segments is a class simple variable.

Example 2 : php – How to get ID from site url in view page

$get_last = end($this->uri->segment_array());

Example 3 : how to get id from view to controller in codeigniter

$total_seg = $this->uri->total_segments();
$get_last = $this->uri->segment($total_seg);

Example

I hope you have Got What is how to pass id from view to controller in codeigniter And how it works.I would Like to have FeadBack From My Blog(Pakainfo.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(Pakainfo.com) Are Most Always Welcome.

Leave a Reply

avatar
  Subscribe  
Notify of