来自MySQL数据库的URL

时间:2019-02-20 11:35:01

标签: php mysql

如何从mysql数据库创建动态网址?

我有一个订阅系统,然后我想为<button class="zoom-in">zoomIn</button> <button class="zoom-stop">stop</button> <button class="zoom-out">zoomOut</button> <div class="element"> <p>Some</p> <p>Text</p> </div>之类的订阅者创建页面
以该顺序。我知道如何使用www.mydomain.com/subscriber1提取数据。

我尝试过

www.mydomain.com/subscribers?subs=ID

2 个答案:

答案 0 :(得分:0)

您也可以通过htaccess来做到这一点。

这是代码

Options -MultiViews
RewriteEngine On

# redirect "/section.php?id=xxx" to "/section/xxx"
RewriteCond %{THE_REQUEST} \s/section\.php\?id=([0-9]+)\s [NC]
RewriteRule ^ /section/%1? [R=301,L]

# internally rewrite "/section/xxx" to "/section.php?id=xxx"
RewriteRule ^section/([0-9]+)$ /section.php?id=$1 [L]

确保在您的Apache配置中启用了mod_rewrite并允许htaccess文件。

答案 1 :(得分:-1)

你在这里。

function links($text){

    // replace non letter or digits by -
    $text = preg_replace('~[^\pL\d]+~u', '-', $text);

    // transliterate
    $text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);

    // remove unwanted characters
    $text = preg_replace('~[^-\w]+~', '', $text);

    // trim
    $text = trim($text, '-');

    // remove duplicate -
    $text = preg_replace('~-+~', '-', $text);

    // lowercase
    $text = strtolower($text);

    if (empty($text)) {
    return 'n-a';
    };

    return $text;

};

echo links('How to create dynamic urls from mysql database?'); 
//how-to-create-dynamic-urls-from-mysql-database