Jump to content

Newby needs your help - Easy PHP :D


astanford10

Recommended Posts

Ok so this is what I am looking for and I cannot seem to find any documentation on it!

 

I have some html files which I want to call up by using the following:

 

engine.php?id=?

 

with the questionmark being 1,2,3,4,5,6, etc... where each number is a different HTML page, I just want it to look a little cleaner then if I just have it redirect to each page itself I mean come on what looks better:

 

http://localhost/engine.php?id=1 <------ :D

http://localhost/home.html

 

Any guidance is welcome.

 

Thanks,

Drew

Link to comment
Share on other sites

I mean make the .html pages into .php, like 1.php, 2.php, etc. Since you can rename them to php and it won't change how they render.

 

Then make your engine.php:

<?php

// engine.php

$getID = (int)$_GET['id'];

if (!isset($_GET['id']))
{
die("Invalid ID selected.");
}

include_once($getID.".php");

?>

 

Then when you go to engine.php?id=5 it will load 5.php in that page.

Link to comment
Share on other sites

I mean make the .html pages into .php, like 1.php, 2.php, etc. Since you can rename them to php and it won't change how they render.

 

Then make your engine.php:

<?php

// engine.php

$getID = (int)$_GET['id'];

if (!isset($_GET['id']))
{
die("Invalid ID selected.");
}

include_once($getID.".php");

?>

 

Then when you go to engine.php?id=5 it will load 5.php in that page.

 

This is close to what I am looking for but I had a engine.php file I wrote 4-5 years back that had something like that but instead of renaming the files to 1.php, 2.php it had a list of file names with IDs and then php would pull from that list and display the file, something like:

 

(Forgot to mention I always change my file extension to .php if that helps.)

 

 

file.php = ID#

 

then once u input say engine.php?id=ID# it would go to that said page.

Link to comment
Share on other sites

<?php

// engine.php

$filesArray = array(
1 => "home.html",
2 => "contact.html",
3 => "anotherpage.html"
);


$getID = (int)$_GET['id'];

if (!isset($_GET['id']))
{
die("Invalid ID selected.");
}

include_once($filesArray[$getID]);

?>

 

That would make it so it's

http://localhost/engine.php?id=1

 

and it would choose home.html.

 

How exactly do you want the links to appear?

Link to comment
Share on other sites

<?php

// engine.php

$filesArray = array(
1 => "home.html",
2 => "contact.html",
3 => "anotherpage.html"
);


$getID = (int)$_GET['id'];

if (!isset($_GET['id']))
{
die("Invalid ID selected.");
}

include_once($filesArray[$getID]);

?>

 

That would make it so it's

http://localhost/engine.php?id=1

 

and it would choose home.html.

 

How exactly do you want the links to appear?

 

Zurev you are my HERO!!!

 

That is exactly what I needed, It is working straight out the doors :).

 

Cannot thank you enough although I feel I may be back in the near future lol.

 

BTW can you recommend any good PHP/MySQL learning guides? I am good with HTML just not so much with PHP/MySQL

Link to comment
Share on other sites

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.