Guest User

Untitled

a guest
Jul 18th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.55 KB | None | 0 0
  1. function getParameters()
  2. {
  3.     $get_cat_id=mysql_query("SELECT category_id FROM categories WHERE parent_id='0'");
  4.     if(mysql_num_rows($get_cat_id)>0)
  5.     {
  6.         while($row=mysql_fetch_assoc($get_cat_id))
  7.         {
  8.             $catid_array[]=$row;
  9.         }
  10.     }
  11.    
  12.     $path='';
  13.     $getString='';
  14.     $param_array=array();
  15.     $getUrl=$_SERVER['REQUEST_URI'];
  16.     if($getUrl{0}!='/')
  17.     {
  18.         $getUrl='/'.$getUrl;
  19.     }
  20.    
  21.     $url_array=parse_url($getUrl);
  22.     $path=isset($url_array['path'])?$url_array['path']:'';
  23.     $queryString=isset($url_array['query'])?$url_array['query']:'';
  24.    
  25.     $parameters=explode("/",$path);
  26.     print_r($parameters);
  27.    
  28.     foreach($parameters as $value)
  29.     {
  30.         $url_query=$value;
  31.         if(!is_numeric($url_query))
  32.         {
  33.             echo $url_query;
  34.             $parameters['p']=$parameters['1'];
  35.         }
  36.         elseif(is_numeric($url_query))
  37.         {
  38.             foreach($catid_array as $value)
  39.             {
  40.                 echo $value;
  41.                
  42.                 if($value==$url_query)
  43.                 {
  44.                     $parameters['p']='categorii';      
  45.                 }
  46.             }
  47.         }
  48.     }
  49.        
  50.         if(isset($parameters[2]))
  51.         {
  52.             $sub_par2=explode('-',$parameters[2]);
  53.             foreach($sub_par2 as $value)
  54.             {
  55.                 if(is_numeric($value))
  56.                 {
  57.                     $parameters['cat_id']=$value;
  58.                 }
  59.             }
  60.         }
  61.    
  62.     if(isset($parameters[2]))
  63.     {
  64.         if ($parameters[2]=='jucarii-pentru-copii-default')
  65.         {
  66.             $parameters['disp_order']='default';
  67.         }
  68.         elseif ($parameters[2]=='jucarii-pentru-copii-crescator')
  69.         {
  70.             $parameters['disp_order']='crescator';
  71.         }
  72.         elseif ($parameters[2]=='jucarii-pentru-copii-descrescator')
  73.         {
  74.             $parameters['disp_order']='descrescator';
  75.         }
  76.     }
  77.    
  78.     return $parameters;
  79.    
  80. }
Add Comment
Please, Sign In to add comment