转到上一个单词的链接

时间:2016-08-04 22:09:20

标签: php header location

我有这个:

    if(mysql_num_rows($raw_results) > 0){ // if one or more rows are returned do following

        while($results = mysql_fetch_array($raw_results)){
        // $results = mysql_fetch_array($raw_results) puts data from database into array, while it's valid it does the loop
        if
            ($results['cod'] == $query){             
            header('Location: /shop-'$results['cod']'.html'); 
                }
            // posts results gotten from database(title and text) you can also show id ($results['id'])
        }

    }

我想去=> webiste.xx / shop-PREVIOUSLY WORD INTRODUCED($ query).html。我怎么能这样做?

1 个答案:

答案 0 :(得分:0)

您的代码中存在语法错误。您的标题字符串未正确连接。

更改

header('Location: /shop-'$results['cod']'.html');

header('Location: /shop-' . $results['cod'] . '.html');

并在重定向之后。不要忘记死或退出你的剧本

header('Location: /shop-' . $results['cod'] . '.html');
die;