I need to do hits count for my production. help me with preg_replace

Now
PHP Code:
$url $_SERVER['REQUEST_URI']; 
if get url http://localhost/index.php?product=29

page = product
n_id = 29

if get url http://localhost/index.php?cat=31

page = cat
n_id = 31

if get url http://localhost/index.php?search=somthing good

page = search
search_names = somthing good

database table

Code MySQL:
CREATE TABLE `hits` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `date` date NOT NULL default '0000-00-00',
  `n_id` varchar(100) NOT NULL,
  `ip` text,
  `hits` text,
  `search_names` text NOT NULL,
  `page` varchar(100) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM;