Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add 1 to filename

Status
Not open for further replies.

andyb2005

IS-IT--Management
Feb 9, 2005
58
GB
Hi

I am building a search page and may pages are numbered:
(i.e) page27.asp

What I would like to do is if the page doesn't exist then to add 1 to the page number to test for that page.

(i.e) page28.asp

I am not sure how to do this but this is what I have thus far:

Code:
<?
$page = $_POST['page'];
$url = "newRainbow/page" . $page . ".asp";

$filename = $url;

if (file_exists($filename)) 
  {
  header("Location: [URL unfurl="true"]http://www.mydomain.com/"[/URL] . $filename);
  exit;
  } 
  
  else 
  {
  I WANT TO BE ABLE TO ADD ONE TO THE FILENAME HERE AND TEST WHETHER IT EXISTS       
  }

?>
 
how about:

do while (!file_exists($filename))
{
$filename = $filename ."1"; //beware that if it doesn't exist at all you will time out. you could add a counter here to break if you need
}

//to protect against timeouts
if (file_exists($filename)
{
header("Location: }
 
Many thanks!

What I ended up doing was something completely different - but have now resolved the issue.

Thanks though!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top