how can I send PHP parametres, get method like .php?id=xx I am using K2 items with Joomla. Currently I am printing out all results fetched from database using PHP. When user clicks on one of the results it should send him to different page and that page should get id of the thing user clicked. How do I do it if joomla shows me sites like: joomla.com/index.php/example-showing-this/

有帮助吗?

解决方案

This is a very broad question, and we'd more details to better help you. On a broad level, you can generate these URLs using PHP and JRoute http://docs.joomla.org/JRoute/1.5

You may also find this thread helpful too https://groups.google.com/forum/?fromgroups#!topic/joomla-dev-general/1548yu9I2jQ

其他提示

When the user is able to click on things this is no longer PHP, this is HTML and javascript. PHP is executed on the server, the result of this execution is the HTML+CSS+Javascript that the user downloads to its pc.

From what you descrived you need to generate the correct HTML+javascript using the PHP variables you get from the database, for example:

echo "<a href=\"your_php_page.php\">Click me</a>";

This will display a link, but it will not pass any parameters, if you want to pass a id using GET you should do it like this:

$id=1234;
echo "<a href=\"your_php_page.php?id=$id\">Click me</a>";

In the your_php_page.php you can receive this id like this:

$id=$_GET['id']; 
//if you are going to use this in a query you should do something like this to prevent injection
$id=$mysqli->real_escape_string($id);

If you want to use POST, you will have to submit a form or use AJAX, but that's more advanced, you should focus on making it work using GET.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top