Jump to content

Nice Looking URLs


abrahamgarcia27

Recommended Posts

How would i write the php and htaccess for nice looking urls like this?

http://forums.phpfreaks.com/forum/13-php-coding-help/

 

I have this php code

function getservices(){
	
	$db = new Database(DB_SERVER, DB_USER, DB_PASS, DB_DATABASE);
	$db->connect();
	//QUERY ACTIVE COLLECTIONS
	$sql = "SELECT service_id, name FROM `".TABLE_SERVICE."`
	ORDER BY sort_order ASC";
	$rows = $db->fetch_all_array($sql);
	foreach($rows as $record){
	echo
	'<li><a href="/services/'.$record['service_id'].'">'.$record['name'].'</a></li>';
	}
}

And the htaccess is as follows

RewriteRule    ^services/([0-9]+)/?$    index.php?action=services&service_id=$1    [NC,L]    #HANDLE SERVICES
Link to comment
https://forums.phpfreaks.com/topic/279334-nice-looking-urls/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.