PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
simonmlewis
DevNet Master
Posts: 4435 Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:
Post
by simonmlewis » Fri Oct 17, 2014 8:14 am
These links don't work.
When we choose A-Z for example, it doesn't update $order and put it in a sessionm it keeps it set to price1 ASC.
I don't think it's the code that's wrong, it's something within HTACCESS, as I don't believe it is even passing it through to the page, the final but of the URL to give it the Order instruction.
Code: Select all
RewriteRule ^categ/([0-9]+) /index.php?page=categ&c=$1 [L]
RewriteRule ^categ/([0-9]+)/([^/]+) /index.php?page=categ&c=$1&cname=$2 [L]
RewriteRule ^categ/page/([0-9]+)/([^/]+)/([0-9]+) /index.php?page=categ&c=$1&cname=$2&pagenum=$3 [L]
Code: Select all
if (!isset($_REQUEST['order']))
{
$order = "price1 ASC";
}
else if (isset($_REQUEST['order'])) {
$order = $_REQUEST['order'];
$_SESSION['order'] = $_REQUEST['order'];
} else if (isset($_SESSION['order'])) {
$order = $_SESSION['order'];
}
echo "<div class='";
if(isset($order))
{
if ($order == "title ASC") { echo "categ_subcategon";}
else
{
echo "categ_subcateg";
}
}
echo "'><a href='/categ/$c/$categreplace&order=title ASC' style='text-decoration: none'>A-Z</a></div>";
echo "<div class='";
if(isset($order))
{
if ($order == "title DESC") { echo "categ_subcategon";}
else
{
echo "categ_subcateg";
}
}
echo "'><a href='/categ/$c/$categreplace&order=title DESC' style='text-decoration: none'>Z-A</a></div>
<div class='";
if(isset($order))
{
if ($order == "price1 ASC") { echo "categ_subcategon";}
else
{
echo "categ_subcateg";
}
}
echo "'><a href='/categ/$c/$categreplace&order=price1 ASC' style='text-decoration: none'>Price (Low-High)</a></div>
<div class='";
if(isset($order))
{
if ($order == "price1 DESC") { echo "categ_subcategon";}
else
{
echo "categ_subcateg";
}
}
echo "'><a href='/categ/$c/$categreplace&order=price1 DESC' style='text-decoration: none'> (High-Low)</a></div><div style='clear: both; width: 500px'/></div><br/>";
echo "$order<div style='clear: both' /></div>";
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
Celauran
Moderator
Posts: 6427 Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada
Post
by Celauran » Fri Oct 17, 2014 8:19 am
simonmlewis wrote: These links don't work.
When we choose A-Z for example
What does this mean? Please provide some sample URLs (i.e. obfuscate the domain if you want, but keep everything else accurate) alongside your rewrite rules. Complete .htaccess would also be handy in case things are matching earlier rules.
simonmlewis
DevNet Master
Posts: 4435 Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:
Post
by simonmlewis » Fri Oct 17, 2014 8:21 am
Apologies
http://www.domain.co.uk/categ/87/Aged-S ... der=price1 DESC
Code: Select all
DirectoryIndex index.html index.htm index.php
order allow,deny
allow from all
RewriteEngine On
Options +FollowSymLinks
Options +Indexes
RewriteRule ^(blog)($|/) - [L]
RewriteRule ^aboutus/?$ /showroom [L]
RewriteRule ^testimonial_uploads/page/([0-9]+) /index.php?page=testimonial_uploads&pagenum=$1 [L]
RewriteRule ^categ/([0-9]+) /index.php?page=categ&c=$1 [L]
RewriteRule ^categ/([0-9]+)/([^/]+) /index.php?page=categ&c=$1&cname=$2 [L]
RewriteRule ^categ/page/([0-9]+)/([^/]+)/([0-9]+) /index.php?page=categ&c=$1&cname=$2&pagenum=$3 [L]
RewriteRule ^ancillaries/([0-9]+)/([^/]+)/([0-9]+)/([^/]+) /index.php?page=ancillaries&c=$1&category=$2&product=$3&h=$4 [L]
RewriteRule ^product/([0-9]+)/([^/]+)/([0-9]+)/([^/]+) /index.php?page=product&c=$1&category=$2&product=$3&h=$4 [L]
RewriteRule ^sample/([^/]+) /index.php?page=sample&c=$1 [L]
RewriteRule ^productsall/([0-9]+)/ /index.php?page=productsall&pagenum=$1/ [L]
RewriteRule ^news/([0-9]+)/([^/]+) /index.php?page=news&id=$1&title=$2 [L]
RewriteRule ^([^/\.]+)/?$ index.php?page=$1 [L]
RewriteRule ^$ index.php?page=home [L]
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
Celauran
Moderator
Posts: 6427 Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada
Post
by Celauran » Fri Oct 17, 2014 8:30 am
Code: Select all
RewriteRule ^categ/([0-9]+) /index.php?page=categ&c=$1 [L]
RewriteRule ^categ/([0-9]+)/([^/]+) /index.php?page=categ&c=$1&cname=$2 [L]
Switch the order of these and add QSA
simonmlewis
DevNet Master
Posts: 4435 Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:
Post
by simonmlewis » Fri Oct 17, 2014 9:39 am
You beauty - what different technically does that make then (yes it worked !!
)
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.