【发布时间】:2009-07-05 02:24:08
【问题描述】:
我正在尝试制作一些不错的网址。
CREATE TABLE IF NOT EXISTS `games` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`title` varchar(200) DEFAULT NULL,
`about` text,
`release_date` int(10) NOT NULL DEFAULT '0'
php
$id = str_replace('_', ' ', $_GET['title']);
$query = mysql_query("SELECT * FROM games WHERE title = '$id'");
$row = mysql_fetch_assoc($query);
if (!mysql_num_rows($query)) exit('This game is not in the database.');
在替换字符方面需要一些帮助。
假设我的一个游戏的标题是 Day of Defeat: Source 我想通过以下方式访问它:Day_of_Defeat_Source。我该怎么做?删除冒号、- 和 & 以及所有这些都没有。现在是:Day_of_Defeat:_Source
但如果我将 : 替换为 _ 它看起来像:Day_of_Defeat__Source
我该如何解决这个问题?
对不起,我的英语很便宜,也许版主可以让这更容易理解。
【问题讨论】: