PDA

View Full Version : [PHP] "Multipage" using PHP



Shhaaauuuunnnnn
September 22nd, 2010, 18:08
My vocabulary/terminology may not be correct but I'm just explaining how to do this.

First we create the blank PHP file. Name it index.php or example.php whatever you want

<?php

?>

So now we will need to put the "mutlipage" into it. We need a name for the "variable" you will use, I'll call it id. Then we need to identify what we want each to do. I will put some initial stuff into it so it does something.

<?php
echo "example.php is showing!!!"; // will be shown regardless of id
if ($_GET['id'] == 'first') // you can use different things than first
{
echo "<br /><br /> FIRST!"; // You can put html in the echo
}
else if ($_GET['id'] == 'second') // you can use different things than second
{
echo "<br /><br /> SECOND!";
}
else // if id is not the previous, this will be done
{
echo "<br /><br /> DEFAULT!";
}

echo "<table><tr>
<td><a href='?'>Home/Default</a></td>
<td><a href='?id=first'>First</a></td>
<td><a href='?id=second'>Second</a></td>
</tr></table>"; // will also be shown regardless of id
?>

Now you can go even further if you want to and make subs of each id. I will just show first with a sub.

<?php
echo "example.php is showing!!!"; // will be shown regardless of id
if ($_GET['id'] == 'first') // you can use different things than first
{
echo "<br /><br /> FIRST!"; // You can put html in the echo
if ($_GET['sub'] == '1')
{
echo "<br /><br /> sub 1!";
}
else if ($_GET['sub'] == '2')
{
echo "<br /><br /> sub 2!";
}
echo "<table border='1'><tr>
<td><a href='?id=first'>first</a></td>
<td><a href='?id=first&sub=1'>first sub 1</a></td>
<td><a href='?id=first&sub=2'>first sub 2</a></td>
</tr></table>"; // will also be shown regardless of id
}
else if ($_GET['id'] == 'second') // you can use different things than second
{
echo "<br /><br />SECOND!";
}
else // if id is not the previous, this will be done
{
echo "<br /><br />DEFAULT!";
}

echo "<table border='1'><tr>
<td><a href='?'>Home/Default</a></td>
<td><a href='?id=first'>First</a></td>
<td><a href='?id=second'>Second</a></td>
</tr></table>"; // will also be shown regardless of id
?>

Faab234
September 22nd, 2010, 18:32
There are already three of these tuts.

Pie`
September 22nd, 2010, 20:11
Only the registered members can see the link.

suspiciously similar looking posts don't you think?

Trey
September 22nd, 2010, 21:32
Locked until you can provide some sort of proof that you didn't just steal this.