The code below is working fine in that it is showing the correct results from the DB, however I would like to change the way the link looks in the URL, currently after being submitted after choosing from the dropdown, it results in: mysitecom/wallpapers/browse.php?pcat=Cars

I want the URL to look like, mysitecom/wallpapers/Cars/

Can anyone show me how to do this ? Thanks

<?

if(!isset($_GET['page'])){ 
    $page = 1; 
} else { 
    $page = $_GET['page']; 
} 
$max_results = 12; 

$te=explode("--",$_GET[pcat]);

/*if($te[1]=="")
{
echo "cat";
}
else
{
echo "Subcat";
}*/
$from = (($page * $max_results) - $max_results); 
if($te[1]=="" and $_GET[pcat])
{
$rateqry="SELECT * FROM userdata,
services 
where 
userdata.user_status='1' 
and 
services.image_name!='' 
and 
services.work_type='$_GET[pcat]' 
and 
services.userid=userdata.user_id  LIMIT $from, $max_results"; 

$rateq=mysql_query($rateqry)or die($rateqry);   






$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM userdata,
services 
where 
userdata.user_status='1' 
and 
services.image_name!='' 
and 
services.work_type='$_GET[pcat]' 
and 
services.userid=userdata.user_id"),0); 

$total_pages = ceil($total_results / $max_results);




$counted=1;
}
else if($te[1]!="" and $_GET[pcat])
{
$rateqry="SELECT * FROM userdata,
services 
where 
userdata.user_status='1' 
and services.image_name!='' 
and services.sub_cat ='$te[1]' 
and services.userid=userdata.user_id LIMIT $from, $max_results";

$rateq=mysql_query($rateqry)or die($rateqry);      
$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM userdata,

services 
where userdata.user_status='1' 
and services.image_name!='' 
and services.work_type ='$te[1]' 
and 
services.userid=userdata.user_id"),0);

$total_pages = ceil($total_results / $max_results);
$counted=1;
}
else
{
$rateqry="SELECT * FROM userdata,
services 
where userdata.user_status='1' 
and services.image_name!='' 
and 
services.userid=userdata.user_id LIMIT $from, $max_results"; 

$rateq=mysql_query($rateqry)or die($rateqry);      
$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM userdata,
services 
where userdata.user_status='1' 
and services.image_name!='' 
and 
services.userid=userdata.user_id"),0); 

$total_pages = ceil($total_results / $max_results);
$counted=1;
}

?>
<SCRIPT language=Javascript>
function action1()
{
    document.form1.action='browse.php';
    document.form1.submit();
}
</SCRIPT>
<table align="center" width="100%" border="0" bordercolor="#eee" rules="rows" cellspacing="0" class="subcats">
  <tr align="center">
    <td valign="top" colspan="4" align="center" ><table width="100%">
      <tr>
        <td width="29%" align="center"><font face="verdana" size="2"><b>Select A Category</b></font></td>
        <td width="71%">



        <form id="form1" name="form1" method="GET" action="">
          <label>
          <select name="pcat" onchange=action1()>
           <option value="">Select One</option>
          <?
//Check for rows and columns
$catq="select * from media_catetory order by category  asc";
$cats=mysql_query($catq);
while($catsl = mysql_fetch_array($cats))
{
?>
    <option value="<?=$catsl[category]?>"><?=$catsl[category]?></option>
      <? $subcat="select * from media_subcat where category='$catsl[category]' order by subcat";
       $subcats=mysql_query($subcat);
       while($subcatsl = mysql_fetch_array($subcats))
       {?>
       <option value="--<?=$subcatsl[subcat]?>">----<?=$subcatsl[subcat]?></option>
       <? }} ?>
      </select>
          </label>
                </form>







        </td>
      </tr>
    </table>      </td>
  </tr>
  <tr align="center">
    <td valign="top" colspan="4" align="center" ><font face="verdana" size="2"><b>BROWSE PHOTOS</b></font> </td>
  </tr>
   <tr  align="center">
  <? while($rateline=mysql_fetch_array($rateq))
       {
       ?>

  <td valign="top" align="left" ><div align="center"><a href="info.php?id=<?=$rateline[PostID]?>"><img src="phpThumb.php?src=yellow_images/<?=$rateline[image_name]?>&w=150&h=150" /></a></div></td>
    <?if($counted%3==0){?>
  </tr>
<tr  align="center"><td> </td></tr>
  <tr  align="center">
    <?}?>
    <?
    $counted=$counted+1;
 }
   ?>
  </tr>
  <tr  align="left"><td>  Select A Page: <?if($page > 1){ 
    $prev = ($page - 1); 
    echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$prev\"><<Previous</a> "; 
} for($i = 1; $i <= $total_pages; $i++){ 
    if(($page) == $i){ 
        echo "$i "; 
        } else { 
            echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> "; 
    } 
} 

// Build Next Link 
if($page < $total_pages){ 
    $next = ($page + 1); 
    echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$next\">Next>></a>"; 
} ?>

At first step this has nothing to do with PHP … google “htaccess redirect”. At second level maybe you should consider strengthening your programming knowledge and than move to a framework that handles those things for you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.