Page 1 of 1

Wondering if this CF technique will work in PHP

Posted: Fri Jan 28, 2005 3:37 pm
by Serengeti
I'm trying to display different results depending on which radio boxes are checked. I want to reload the page while passing variables that will steer the code to the appropriate SELECT statement.

I'm trying to modify my current code, but since I'm hitting walls, I might have to rewrite the original.

I've looked into parse_str but it isn't receiving the variables. I'm sure it works, but I think the problem is in how I'm sending the variables thru the URL.


Walkthrough:
User loads php page that lists all records in database.
User wants to display only the Red ones and without preview photos.
User selects the appropriate radio buttons and clicks Submit.
Code receives color=red and photos=no.
Code brings up the right SELECT version.
Page reloads with the sorted information.

I've done this many times in ColdFusion, but I think I'm missing something in PHP.

Posted: Fri Jan 28, 2005 3:39 pm
by feyd
it's mostly just a matter of adding the right "if" checks.

Posted: Fri Jan 28, 2005 3:55 pm
by Serengeti
I've looked around. Found a lot of stuff on encoding variables thru URLS. Not sure what I should look for.

What would be the MySQL/PHP equivalent of this MSSQL/CF query?

SELECT * FROM MEMBERLIST
WHERE COLOR = '#Form.Color#';


Am I making this too hard on myself? lol

Posted: Fri Jan 28, 2005 4:01 pm
by Serengeti
I was working this angle...but it wont even print the variables.

function parseURLVariables () {

$URLColor=$color;
$DisplayPhotos=$photos;
// $URLColor=$_GET['color'];
// $DisplayPhotos=$_GET['photos'];

print("$URLColor<br />$DisplayPhotos");
}

Posted: Fri Jan 28, 2005 4:05 pm
by feyd
both $color and $photos should not exist inside that function. Even if you have register_globals on. (which you shouldn't.)

When possible, pass the information into a function.. it's a lot more flexible for if and when you change the code or purpose.