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
https://forums.phpfreaks.com/topic/223440-newby-needs-your-help-easy-php-d/
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.

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.

<?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?

<?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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.