求php跳转到不同页的问题!

来源:百度知道 编辑:UC知道 时间:2024/06/05 10:32:28
我有一段代码
preg_match_all( "/\<PRESULT\>(.*?)\<\/PRESULT\>/s", $xml, $allgoods ); //xml产品单元
if (!preg_match_all( "/\<PRESULT\>(.*?)\<\/PRESULT\>/s", $xml, $allgoods ))
echo "抱歉哦!请您刷新下页面再看下!或者换个关键词查询";
我想将这段代码改成如果找不到xml产品单元,输出的不是这行字,而是跳转到相对应的页面,而那个页面不是固定的!
比如A页面class.php?cat=281303的这段代码没有返回数据,则跳转到list.php?hat=281303 ,
页面不是固定的,但是后面的281303 是一样的,我该怎么做!
谢谢了
问题补充:class.php?cat=281303 中的 281303 是变化的, 比如说是一个函数<?=$contact?> ,该怎么办啊

if (!preg_match_all( "/\<PRESULT\>(.*?)\<\/PRESULT\>/s", $xml, $allgoods ))
header("Location:class.php?cat=".$contact);//这里你要设置好路径如果class.php跟当前路径是一样的,可以这样设置。