Wondering if this CF technique will work in PHP

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

Post Reply
Serengeti
Forum Newbie
Posts: 19
Joined: Sat Jan 22, 2005 1:58 am

Wondering if this CF technique will work in PHP

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

it's mostly just a matter of adding the right "if" checks.
Serengeti
Forum Newbie
Posts: 19
Joined: Sat Jan 22, 2005 1:58 am

Post 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
Serengeti
Forum Newbie
Posts: 19
Joined: Sat Jan 22, 2005 1:58 am

Post 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");
}
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
Post Reply