Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/entity-framework/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 转到与上一个单词的链接_Php_Header_Location - Fatal编程技术网

Php 转到与上一个单词的链接

Php 转到与上一个单词的链接,php,header,location,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,

我有这个:

    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-WORD-imported($query).html。如何执行此操作?

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

改变

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

header('Location: /shop-' . $results['cod'] . '.html');
在重定向之后。不要忘记死亡或退出脚本

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

你的问题不清楚。如果您给我们举个例子,并进一步解释“前一个单词”
标题('Location:/shop-'.$results['cod'..html')的含义,可能会有所帮助;退出工作。谢谢您。