Link to home
Start Free TrialLog in
Avatar of GD_GRAY
GD_GRAYFlag for United States of America

asked on

Open pdf file in new window from one of two folders with php

I have two folders, one with pdf files starting with P in the Place folder, and the other with files starting with C in the Country folder.

If I use a link like
<a target='_blank' href='http//myhost.com/sort.php?trip=$row[trip_number]'>" . $row['trip_number'] . "</a>  

And than in the sort.php script use this
$trip = (isset($_GET["trip"])) ? $_GET["trip"] : 0;

What can I use to take the $_GET["trip"] and redirect the request to the right folder and open the file in the parent window. I was thinking that the if statement might work like

if $trip = p*.pdf than redirect to place/$trip, if not redirect to country/$trip and if it cant find the file echo not on file and not the 404

but as you see I have no idea how to write it. Also any other way of doing this is fine if you have one. This is all I could come up with....  Thanks
ASKER CERTIFIED SOLUTION
Avatar of ahoffmann
ahoffmann
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of GD_GRAY

ASKER

Sorry to ask but how would I put that into play ?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of GD_GRAY

ASKER

Wow, your the bomb. thank you . I set the redirect up to use $dir/$trip and got what i need,