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+, ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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 :) |
|
|||
|
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. |
|
|||
|
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> |
|
|||
|
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. |
|
|||
|
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. :) |
![]() |
| Thread Tools | |
| Display Modes | |
|
|