Jump to content

Recommended Posts

Hi all.

I am in need of some help with a simple page search function.

In short what i need is a way the user can search for a specific page name from the home index page.

My site (local for now) will be constructed as follows:

localhost/mysite/index.html

0001.html

0002.html

...

0132.html

etc...

The subpages will be added/modified externaly and may run into the hundreds of pages.

For this reason mySQL will be hard to implement and somewhat overkill especialy for this simple search function.

So, is there a way i can type the page to look for "0132" into the field and be forwarded onto the searched page "0132.html"

I realise i could just type mysite/0132.html but the page may or may not exist and searching would be tiny bit more elegant.

Simple for you guys i expect but im at a loss as all search functions use mySQL in addition.

Many thanks for your help in advance!

Regards, Matt.

 

Link to comment
https://forums.phpfreaks.com/topic/310341-php-page-name-searchforwarding/
Share on other sites

What type of website are you building? Is it a blog or some kind of resource library? In other words, would the contents of all these pages be better suited for a database? Perhaps there's a way to build a single page in PHP which pulls the necessary information from the database based on a passed ID.

Thanks for the suggestion, ill look into that.

Sadly a database is out of the question as the pages i wish to add will be created by an external script. Basically i need a means of tracking deliveries of interbranch transfers, my store is a hub and id like to post tracking data for items shipped out (this is the part thats handled by a script running outside the website environment). Pages will be updated with order tracker info and dumped into the web server folder so i need a way a user can search by 6 digit order number which will pertain to the html file containing the afformentioned info.

Regards.

So - these people have the power/permission to add these built pages to your site?  Is that why you won't know if they exist or not.

	$pageno = (some source - perhaps the current url);
	if (is_file( $path . "/$pageno". "html"))
	{
	    header("Location: $path . $pageno . '.html');
	    exit();
	}
	

This all depends on the source of the page number and what location the pages are all stored in.  Basically this is what I would do once my script figures those things out.  Of course you have to decide how to handle the non-existent file condition.

 

Edited by ginerjm
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.