Jump to content

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/158257-avarcade-4-slugs/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.