Szise Posted May 15, 2009 Share Posted May 15, 2009 Hello everyone, I'm not good with php but... I'm trying to build a site using a free script AVAarcade, like most game scripts it's using IDs to generate the pages. example : www.website.tld/view/12345/the-game-i-play/ What i want is to get rid of the IDs and replace them with a slug. What i have done, i created a new column for my database next to "name" and "id" called "slug" and writed the description for that game. example : name: The Game I Play slug: the-game-i-play id: 12345 Now the problem is that i can call the script to use the slug insted of the ID. Let's take a file : /modules/popular.php It has the following content and displays the most popular games: <? ## # AV ARCADE v3 # popular.php # Loads the most popular games/media module ## $sql = mysql_query("SELECT * FROM ava_games WHERE published=1 ORDER BY hits desc LIMIT 10"); while($row = mysql_fetch_array($sql)) { $abcd= $row['name']; $abcd = str_replace (" ", "-", $abcd); if ($seo_on == 0) { $url = 'index.php?task=view&id='.$row['id'].''; } else { $url = 'view/'.$row['id'].'/'.$abcd.'/'; } echo ' <a href="'.$site_url.'/'.$url.'">'.$row['name'].'</a><br>'; } ?> I changed the code like this to use the slug not the id like this but doesn't work: <? ## # AV ARCADE v3 # popular.php # Loads the most popular games/media module ## $slug = intval($_GET['slug']); $sql = mysql_query("SELECT * FROM ava_games WHERE slug=".$slug.""); while($row = mysql_fetch_array($sql)) { if ($seo_on == 0) { $url = 'index.php?task=view&slug='.$row['slug'].''; } else { $url = 'view/'.$slug.''; } echo ' <a href="'.$site_url.'/'.$url.'">'.$row['name'].'</a><br>'; } ?> Also i changed added this line in .htaccess but can make it work. RewriteRule ^view/([0-9a-zA-Z?-]+) index.php?task=view&id=$1&name=$2 [L] Can someone help me with the issue ? i want to make the script take the slug from my databese and create the new game page, with the url like this www.website.tld/view/the-game-i-play/. P.S. the AVarcade version is 4. Quote Link to comment https://forums.phpfreaks.com/topic/158257-avarcade-4-slugs/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.