Using + as a url variable term

This is a discussion on Using + as a url variable term within the PHP General forums, part of the PHP Programming Forums category; Hi, I'm trying to have a group of reviews for a site I run be sorted by rating (A+, ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-11-2006
cassyeva@gmail.com
 
Posts: n/a
Default Using + as a url variable term

Hi,

I'm trying to have a group of reviews for a site I run be sorted by
rating (A+, A, A-, etc), where the rating is in a column of it's own.
The regular letters (A, B, C, D, F) work fine, and the minuses (A-, B-,
C-, D-) work fine. When you try to go to a page for the pluses though
(A+, B+, C+, D+), they just go to the regular pages. I really don't
want to have to go back and change this to something else, there are
hundreds of reviews. Is there a way to make this work?

The url would need to look something like this:

www.mysite.com/rating.php?rating_rev=B+

I was thinking of some kind of replace tool for the URL, so I wouldn't
have to change the fields in the database itself.

Please help. I've programmed the rest of this site on my own, but I'm
totally stuck here :)

Reply With Quote
  #2 (permalink)  
Old 05-11-2006
George Mills
 
Posts: n/a
Default Re: Using + as a url variable term

cassyeva@gmail.com wrote:
> Hi,
>
> I'm trying to have a group of reviews for a site I run be sorted by
> rating (A+, A, A-, etc), where the rating is in a column of it's own.
> The regular letters (A, B, C, D, F) work fine, and the minuses (A-, B-,
> C-, D-) work fine. When you try to go to a page for the pluses though
> (A+, B+, C+, D+), they just go to the regular pages. I really don't
> want to have to go back and change this to something else, there are
> hundreds of reviews. Is there a way to make this work?
>
> The url would need to look something like this:
>
> www.mysite.com/rating.php?rating_rev=B+
>
> I was thinking of some kind of replace tool for the URL, so I wouldn't
> have to change the fields in the database itself.
>
> Please help. I've programmed the rest of this site on my own, but I'm
> totally stuck here :)
>

Don't know if this would be doable but what about a little translator
before the input/display and after the $rating_rev =
$_GET['rating_review'] that turned '+' to plus and '-' to minus.
(Someone once name a programming laguage with these characters and
caused all kinds of problems.)

There is probably an easier solution.
Reply With Quote
  #3 (permalink)  
Old 05-11-2006
ZeldorBlat
 
Posts: n/a
Default Re: Using + as a url variable term


cassyeva@gmail.com wrote:
> Hi,
>
> I'm trying to have a group of reviews for a site I run be sorted by
> rating (A+, A, A-, etc), where the rating is in a column of it's own.
> The regular letters (A, B, C, D, F) work fine, and the minuses (A-, B-,
> C-, D-) work fine. When you try to go to a page for the pluses though
> (A+, B+, C+, D+), they just go to the regular pages. I really don't
> want to have to go back and change this to something else, there are
> hundreds of reviews. Is there a way to make this work?
>
> The url would need to look something like this:
>
> www.mysite.com/rating.php?rating_rev=B+
>
> I was thinking of some kind of replace tool for the URL, so I wouldn't
> have to change the fields in the database itself.
>
> Please help. I've programmed the rest of this site on my own, but I'm
> totally stuck here :)


When used in a URL the "+" actually means " " (space). I'd suggest
URL-encoding your parameters as a matter of habbit -- not only in this
case. Either way, you want:

<http://www.php.net/urlencode>

Reply With Quote
  #4 (permalink)  
Old 05-12-2006
cassyeva@gmail.com
 
Posts: n/a
Default Re: Using + as a url variable term

I'm not sure I understand what to do. I went to the page, but don't see
how I can fix my problem. There doesn't seem to be any code for "+."

Reply With Quote
  #5 (permalink)  
Old 05-12-2006
George Mills
 
Posts: n/a
Default Re: Using + as a url variable term

cassyeva@gmail.com wrote:
> I'm not sure I understand what to do. I went to the page, but don't see
> how I can fix my problem. There doesn't seem to be any code for "+."
>

%2B if I read http://www.lookuptables.com/ correctly or

if ($rating = $_REQUEST['rating']) {// I read request decoded by default
$sql = "select id from table_foo where rating = '$rating'";
mysql_query($sql) or die "Ah, ya got me!";
...
} else {
$rating = "A+";
$rating = urlencode($rating);
echo "<a href=\"www.yoursite.com?sites_rated=$rating\">";
}


Some please correct me if I goofed that.
Reply With Quote
  #6 (permalink)  
Old 05-12-2006
cassyeva@gmail.com
 
Posts: n/a
Default Re: Using + as a url variable term

%2B worked perfect; all I did was replace the "+" with that in my links
and I didn't have to change anything in the db. Thanks so much!

Reply With Quote
  #7 (permalink)  
Old 05-12-2006
George Mills
 
Posts: n/a
Default Re: Using + as a url variable term

cassyeva@gmail.com wrote:
> %2B worked perfect; all I did was replace the "+" with that in my links
> and I didn't have to change anything in the db. Thanks so much!
>


Your welcome. I think ZeldorBlat's answer is a better fix but as long as
it works. You could always try C%2B%2B. :)
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 03:02 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0