从URL获取参数而不使用$ _GET

时间:2013-02-02 23:05:57

标签: php get mysqli

基本上尝试为我的mysql中的每个条目创建一个页面,并且单击后的每个条目都将被重定向到一个页面,其中显示了深入的数据。 Page的例子:.... www.example.com/examplepage.php/3 3是$ row [0],这是条目的ID#

    while ($row = $result->fetch_row()) {

$article_page = "http://localhost/MCA/testpage.php/$row[0]";

echo '<tr><td><a href=' . "$article_page" .'>' . $row[1] . '</a></td><td>' .
                            $row[2] . '</td><td>' .
                            $row[3] . '</td><td>' . 
                            $row[4] .'</td><td>' . 
    date("l jS \of F Y h:i:s A", strtotime($row[5])) .'</td></tr>';

     }

2 个答案:

答案 0 :(得分:2)

您需要通过.htaccess文件或其他方式应用URI重定向规则。

更改的示例如下:

<强>的.htaccess

Options +FollowSymLinks
IndexIgnore */*

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php

<强> PHP

$uri_segments = explode('/', $_SERVER['REQUEST_URI']);

答案 1 :(得分:0)

您必须使用URL重写以干净的方式执行此操作。 (见httpd mod_rewrite)。

相关问题