Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2012-03-29
4
Medium Priority
?
386 Views
Last Modified: 2012-08-13
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
0
Comment
Question by:GD_GRAY
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 51

Accepted Solution

by:
ahoffmann earned 2000 total points
ID: 37783414
$dir="country/";
if(preg_match('/^p/i',$trip)){$dir="place/";}
0
 

Author Comment

by:GD_GRAY
ID: 37783866
Sorry to ask but how would I put that into play ?
0
 
LVL 51

Assisted Solution

by:ahoffmann
ahoffmann earned 2000 total points
ID: 37784050
in the php script which is called by the links
0
 

Author Closing Comment

by:GD_GRAY
ID: 37784332
Wow, your the bomb. thank you . I set the redirect up to use $dir/$trip and got what i need,
0

Featured Post

What Is Blockchain Technology?

Blockchain is a technology that underpins the success of Bitcoin and other digital currencies, but it has uses far beyond finance. Learn how blockchain works and why it is proving disruptive to other areas of IT.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question