friiks
Feb 28 2007, 08:43 PM
Was just sitting and being bored but then I realized I could show how to create more or less popular ?id=page browsing. It's actually really easy. I know two ways how to do it. First one I learned was checking the variable and if it's true including the text/file/anything needed and so on. It was ok, but sometimes I just couldn't make it work so I switched to switch() function and that's what I'm going to show you guys right now. So, I made a test page which contains the code needed and here is its source. CODE <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html> <head> <title>Untitled</title> </head> <body> <a href="?p=idx">Home</a> - <a href="?p=pagetwo">Page Two</a> - <a href="?p=pagethree">Page Three</a><br> <?php $page=$_GET['p']; switch($page){ default: echo 'This is the default page'; break; case 'pagetwo': echo 'This is page two'; break; case 'pagethree': echo 'This is page three<br>Cool, huh?'; } ?> </body> </html> Okies, I'll split up the code and explain it to you. I'll start with the links CODE <a href="?p=idx">Home</a> - <a href="?p=pagetwo">Page Two</a> - <a href="?p=pagethree">Page Three</a><br> Those are normal html links only their href leads to links like ?p= ...well replace p with letter or a word you want - mind that you can't put spaces there..well, maybe you can but..don't do that. Now for the PHP. CODE <?php $page=$_GET['p']; <?php starts php code $page=$_GET['p']; sets the $page variable to the page requested. Um, you have to change p in $_GET['p'] to word/letter you use for your links. $_GET gets the info from the url (in this tutorial  ) CODE switch($page){ default: echo 'This is the default page'; break; case 'pagetwo': echo 'This is page two'; break; case 'pagethree': echo 'This is page three<br>Cool, huh?'; } switch($page){ Um, this part of code uses switch function to switch parts of code by using the $page variable. default: sets the default page that will be shown when user inputs an invalid url and the content that will be shown in index page. You see the echo() function in next line. You can input anything there...echo text/include file...use your imagination. Just put what you want to see in the default page. break; ends execution of the current switch structure. Can't really explain it but that. Ok, now for the part you want to see so bad. case 'pagetwo': ...see anything in common with the previous code I've shown? If you guessed <a href='?p=pagetwo'> then you are correct. If the $page variable is set to pagetwo switch function will switch the content to the content you will put after the colon. Same thing works for the rest of the code. You add a case'': checking for a variable, put the code to show it is true, use break to break the code and add next case. When you have added all the pages you want you just put a curved bracket (Like here I have done all my pages and want to end it. CODE case 'pagethree': echo 'This is page three<br>Cool, huh?'; } ) and voila, your links are working. Hope that helps you at least a little. Ask if you have any questions, corrections or suggestions. Oh, and here's the link to a preview. Cheers, Matt.
Reply
JDameron91
Mar 1 2007, 09:39 PM
Cool dude, very useful. When I used to go to 64Digits I always wondered how they used that system. Now, that you've used it on my site I was able to see the code and learned greatly from that.  Very nice example, and I know everybody on this forum will agree when they get on to see it.
Reply
Imtay22
Mar 19 2007, 07:41 PM
when i do it it turns up like this- Link. It says the same thing everytime I tried to do it. PLease help!
Reply
friiks
Mar 19 2007, 07:54 PM
Show me the code you're using ,please!
Reply
matak
Mar 19 2007, 08:06 PM
this code works for me... CODE <a href="?p=idx">Home</a> - <a href="?p=pagetwo">Page Two</a> - <a href="?p=pagethree">Page Three</a><br> <?php $page=$_GET['p']; switch($page){ default: echo 'This is the default page'; break; case 'pagetwo': echo 'This is page two'; break; case 'pagethree': echo 'This is page three<br>Cool, huh?'; } ?>
Reply
Imtay22
Mar 19 2007, 08:08 PM
QUOTE(matak @ Mar 19 2007, 03:06 PM)  this code works for me... CODE <a href="?p=idx">Home</a> - <a href="?p=pagetwo">Page Two</a> - <a href="?p=pagethree">Page Three</a><br> <?php $page=$_GET['p']; switch($page){ default: echo 'This is the default page'; break; case 'pagetwo': echo 'This is page two'; break; case 'pagethree': echo 'This is page three<br>Cool, huh?'; } ?> It displays this- QUOTE Home - Page Two - Page Three Cool, huh?'; } ?> On every page
Reply
electriic ink
Mar 19 2007, 08:20 PM
I don't know what the problem is but default: should always be the last case statement: CODE <a href="?p=idx">Home</a> - <a href="?p=pagetwo">Page Two</a> - <a href="?p=pagethree">Page Three</a><br> <?php $page=$_GET['p']; switch($page){ case 'pagetwo': echo 'This is page two'; break; case 'pagethree': echo 'This is page three<br>Cool, huh?'; break; default: echo 'This is the default page'; } ?> Maybe that's the problem.
Reply
friiks
Mar 19 2007, 09:31 PM
Wow, I never knew that.. But anyways I've been always using it this way AND it has always worked..
Reply
friiks
Mar 20 2007, 02:22 PM
Woah, I had a typo in my code  Corrected it, thanks to matak for pointing it out
Reply
street
Mar 20 2007, 04:40 PM
wow thanks for putting this tutorial up i have been to many sites where it just shows the page name in the href i always thought it was the way they had name there pages but it is all just a simple php code. I am going to start using this.
Reply
Mariana
Jun 11 2007, 01:45 AM
Yay, that was very helpful.. Thanks =3
Reply
jlhaslip
Jun 10 2007, 07:41 PM
reconraiders, post your source code in a new thread, please. Chances are that you are adding the new query string onto the end of the existing, instead of clearing the old query string first.
Reply
reconraiders
Jun 10 2007, 07:13 PM
A while back I used something like this but for some reason the links were getting messed up. Whenever I would click a link with parameters in it (?page=2&action=view) from a page that already had parameters in the url, it would add the parameters to the page. I would end up going to a url "index.php?page=1&action=add?page=2&action=view". I didn't understand why. Is there a setting in php to adjust to fix this?
Reply
jlhaslip
Mar 22 2007, 05:36 PM
Nice code, but use the following query string to see what happens. CODE p=test You need to find a way to always end up at the index.php page, otherwise the client gets a header with no "page" content. Also, move the array outside the page code to a text file so the entire page doesn't need to be editted, only the text file. Makes it a bit more user friendly. ( and safer to update the link array without damaging the page )  Keep trying. http://www.trap17.com/forums/templating-sy...des-t35271.html (I'll send the zip if you want. I took it off the net due to a small (potential) security problem)
Reply
matak
Mar 22 2007, 04:59 PM
After a while struggling with PHP arrays in order to build even more dynamic, more like administrator friendly dynamic links i figured out it could be done this way. First we need to build ourselves an associative array like this CODE $glavni_linkovi = array( "Index" => "This is the index file!", "Link1" => "This is path to link1!!", "Link2" => "This is path to link2!!", "Link3" => "This is path to link3!! :)" ); After we made our array with foreach statement we can make our links. I made it something like this CODE foreach ($glavni_linkovi as $gl_li => $gl_li_path) { echo '<a href="?p='.$gl_li_path.'">'.$gl_li.'</a> '; } Now we go to the part where we use $_GET like posted above to use that associative array in our page. Code looks a bit messy but it's couse i didn't know any other way to use Default switch with foreach statement.. Here's the code CODE $page = $_GET['p']; if ($page == "") { echo $glavni_linkovi['Index']; } else { foreach ($glavni_linkovi as $gl_li => $gl_li_path) { switch($page) { case $gl_li_path: echo $gl_li_path; break; } } } This can be quite handy beacouse we don't need to write switch statement every time when we create link. Also we don't need to write links manualy, beacouse they are created automaticly when added to associative array.. Hope u Like this example. Here's how it works. Link. And here's the download zippy if you don't understand how to implement it in webpage.. Zippy  Thanks to all trap17 coders! matak
Reply
Similar Topics
Keywords : making popular id browsing site- [aef] Most Recent Topics Listing Mod
- on your Web-site pages (2)
- Php Word Filter
- Have you accidently sworn on your site? Or do you want to keep visitor (9)
This is pretty simple but very useful if you don't want people to swear. We will be using
str_replace for this. CODE <?php str_replace ("curseword,
"replacemet"); ?> Thats pretty simple, just fill in the curse word and the
replacement, and then repeat... heres what it would look like full size: CODE <?php
str_replace("swear", "replacement"); str_replace("swear",
"replacement"); str_replace("swear", "replacement");
str_replace("swear", "...
Making Winrar Archives
- and adding password to winrar archives (13)
**** This tutorial will show you how to put files into .rar Archive and pass worded (if wanted)
**** What You Will Need Before continuing you will need a couple of thing, first of all you
need WINRAR , which is a very powerful archive manager. It can reduce size for you email
attachments, decompress RAR, ZIP and other types of files downloaded from the internet. You can get
winrar at http://www.rarlabs.com The other thing is that make sure your using Windows XP because
this is what I used to make this tutorial. I think it works with any other windows not...
Making A Song In Fruity Loops Part Three
- part three precusion (1)
ok part three now which covers the precusions setup of the small song i built for this tutorial.
the nesecery files can be downloaded here the image below is included in the precusions folder as
it mught not be entierly visable within this post so shold you need it its there also the images
purpose is to enable you to see what i am refering to within this tutorial lateron. now what i
have done above is blackd out every pattern that has nothing to do with the precusion. so the
patterns displayed in light grey are the only patterns i will be refering to. ok lets b...
Ftp In Visual Basic 6.0
- Start making your FTP client using VB6 (1)
Recently, I had a need to make a FTP client, since our webhosting FTP server was kind of exotic, and
very restrictive, and most of uploads, even though they reach 100% would crash... File would be
uploaded to a server, but FTP clients just froze upon completion, waiting for the 226 (OK) from FTP
server... So, I had to make my own, one who would not wait for 226, but instead, watch the file
pload progress... This tutorial is not fuly complete, in the sense that it does not offer COMPLETE
FTP client functionality (for example, I ddn't write the code for FTP download, ...
Making Calculators with PHP
- Some basic calculator scripts I made. (4)
Yes, I made some basic calculators to use for simple math problems, nothing big. I'm a newbie at
php, so if I made something that could be short, long, I am sorry. lol Here is one for adding two
numbers. CODE <html> <title>Adding 2 numbers </title> <body>
<h3 align="center">Type in the two numbers you'd like to add
together.</h3> <form action="add2.php" method="post"> <input
type="text" name="number1" /><p>+</p> <input type="tex...
Php Quiz Script
- Make quizzes for your site. (20)
Hello all, A little bit back I decided to make a quiz scriptjust out of no where lol. However it
doesnt do anything special but I am going to make an email mod for it so that it will email results
to your email address. So here is the basis of it. INSTRUCTIONS: Open a new page in your text
editor and paste in the following code. CODE <?php $qid = "Quiz ID-00"; ?>
<html> <head> <title><? echo "Gamers Pub $qid";
?></title> </head> <body> <p><h3><? echo "...
How To Make An Ultimate Game List.
- If you're making a site on video games or such. (0)
Hello. I am BuBBaG. You can call me Bubba for short. I'm going to show you how to make an
Ultimate Game List. First off, we need to make a database, we are going to call this database
`my_db`, leave out the `'s. Inside that database we will need to create a table
called `ugl'(Ultimate Game List, duh). To make the table, simply enter this in the Syntax.
CODE CREATE TABLE ugl ( System char(50), Game char(50), ) In the
above code, it is stating we are creating a table called ugl, with two columns, System, and Gam...
Create A Google Seach Result Page Embed Within Your Site Page.
- (12)
Create a google seach result page embed within your site page. It is easier to create
web page that embeded the google search result in it. The first step is to go to google apply an
account for the google ad-sense. After that login to you account and choose the create ad-seach
option. Most of time the google search box give all we have the great and powerfull seach ability.
But, have you think every time users get seach with it. They do redirected to another page that is
not within you site. It is easier to create web page that embeded the google sea...
How To: Make A Simple Php Site
- Making one file show up on all pages using php (21)
I have looked all over the site and could not find anything that was like this simple, or just like
this at all.. For some people i know that you are using a basic HTML site...and having a big menu
if you want to add somthing you have to go into every one of the pages and add or remove or edit
what you want to do, but with somthing verry simple all you would have to do is edit one file, and
all of the pages that have the PHP script on them would suddenly change to what that one file is.
So to start off if you are planning on using this little tirck, the page that you a...
Css And Javascript Combined For Dynamic Layout
- use of different CSS files at same site (9)
This tutorial is meant for people that are dealing with problems while coding their site at 100% of
width. Important notice: Some people has JavaScript disabled, so they will not be able to load CSS
file (take this in account when creating your website). How this script works. In the HEAD of your
HTML document will apply this command, so variable.js file will be load at start: CODE
<script type="text/javascript" src="variable.js"></script> In
browser JavaScript file variable.js is loaded. This Javascript file consist of this para...
Tutorial: Installing D-shoutbox For Ipb V1.2
- Making your installation even easier (12)
Over the course of the summer I have tried hard to install a shoutbox into a new forum I was
developing. I went to the Invisionalize forums and found several mods for shoutboxes, but none of
them seemed to work. I first tried to install the D-Shoutbox, but upon this first try, I was
unsuccessful. Eventually, after much frustration, and trying other mods, which didn't seem to
stack up to Dean's features, I was determined to make it work. For some, editing your files (to
the newbie that is) can be difficult, with everything looking like a foreign language (basi...
How To Put A Phpbb Login Box On Your Main Site.
- Code and .php included!!! (18)
I have included my coded file with this... Ok here is the code. CODE // //Create login area,
replace the phpBB2 in /phpBB2/login.php with your forum's //directory // <form
action="/phpBB2/login.php" method="post" target="_top"> <table
width="25%" cellspacing="2" cellpadding="2" border="0"
align="center"> <tr> <td align="left"
class="nav"><a href="/phpBB2/index.php" class="nav">Prank Place
Forum Index</a></td>...
Making Interactive Cds With Flash
- My second flash tutorial for Beginners (2)
Im back again with what i think it would be an interesting tutorial for all of you guys who wants to
take flash out of the web and make really cool interactive CDS. First of all if all of you are
thinking right now: "this dude is wrong for making interactive cds you have to use macromedia
Director", well you are right macromedia director it's used to build interactive cds and dvds
among other things, but you can also make interactive cds with Flash, the thing is: if you want to
make a simple interactive CD you can totally do it with flash, of course Director brings ...
Simple Stylesheet Tutorial
- Stylesheet embedded in your site. (2)
Hi - ill show you how to make a simple style sheet that will be embedded into your site. OK make
sure your site is set up already (like the standard tags) To start and end off a stylesheet you
need to do the following CODE <style type="text/css"> </stlye> Ok
lets start CODE <style type="text/css"> p { font-family: "Tahoma";
font-size: 9; color: "red"; } </style> So when you come to put in
CODE <p>Hi!</p> The text will appear red and will be in Tahom...
How To Make A Very Simple Wap Site
- A quick tutorial about WML language (40)
WAP Site Tutorial : How to Make A Wap site? Before We begin.. Defination from the
Web about Wap. QUOTE WAP is an open international standard for applications that use
wireless communication . Its principal application is to enable access to the Internet from a
mobile phone or PDA .A WAP browser provides all of the basic services of a computer based web
browser but simplified to operate within the restrictions of a mobile phone. WAP is now the
protocol used for the majority of the world's mobile internet sites, known as WAP sites ...
Phpbb Forum Site Transfer
- How to do it, step by step instructions (20)
I'm sure many of you out there have used phpBB at some point. To those who enjoy running forums
and online communities, specifically supporting phpBB, I am about to tell everyone how to restore
the forums database from one website, to another. This is presuming you do not have any mods or
hacks installed. Some of you may find this information useful. Here is the scenario: Let's say
you have forums running phpBB version 2.0.17 (currently the latest one). You have decided that you
want to move your forums to a whole new URL and provider, and as an added bonus, ch...
Php Emailer/contact System
- An email or contact system for your site (20)
Hello all, Here is an easy Emailer or Contact system that allows visitors or members of your site
to email you just by filling out a form. So here is what you need to do to set it up. First open up
a new page in your text editor and paste in the following code. CODE <?php $Name =
$_POST['Name']; $Subject = $_POST['Subject'];
$Email = $_POST['Email']; $Site =
$_POST['Site']; $Message=$_POST['Message'];
$align = $_POST[...
Checking The Web Site Speed
- (10)
Did you taking too much time to access your favorite sites? Probably the problem is on the server
used by those sites. To make sure that is the problem, use Windows PING facility. Ping is a small
program, which sends a 32-bit signal to the Web site server. Next, Ping record the time needed by
the server to answer it. To activate Ping: Click on the Start-Run menus, type command, and then
click OK. Type PING "site name" in the MS-DOS prompt window, for example PING www.yahoo.com. In a
moment, the result will appear on the screen. A result less than 300ms is normal spee...
Making A Song In Fruity Loops Part 2
- part 2 the second melody (0)
ok i am going to attach the midi file againe incase you didnt get it from the first part in this
part i will demonstright how to create and insert the second mellody ok so you have your first
mellody wich is ecetially the comein chord as i call it. now open the midi file you put in your left
panel during the first tutorial and drag the mellody 2 © onto the pallet but click on pattern two
in the right site playlist box. now like in the first tutorial replace with sytrus. for this type
of mellody use something in the leads section of the plugin.for this you need to ...
How To Set Up A Bookmarking System On Wii
- Use your favorite social bookmarking site. (0)
This is a simple tutorial on a way to set up a bookmarking system on your Wii with greater stroage
than the Favorites. It is more complicated than the Favorites and requires manual URL typing. Well
let's dive on in. Items Required Nintendo Wii Internet Channel 3 Empty Favorites Internet
Connection An account on a social bookmarking site I will be using delicious as an example.
delicious Ok, if you do not have an account, read on. If you do have an account, go to the
{account} section. Ok, first you need to register an account. This can be done by clicki...
Faux Ajax Loading - Css Only
- Pretend your site is Ajax based (3)
Link: http://www.jlhaslip.trap17.com/samples/misc/ajax/index.html Check that out. The first page
has information and the second and has the actual example of its use with sample CSS code. I find
that when you visit a site which has a slow server and attempt to view 'large' Image files,
it is pretty boring to sit and stare at a blank screen, so this little snippet of code can be used
to give the visitor something to see to indicate that the image is being downloaded. I built a
small animated gif that sits in the background of the space allocated for the image...
Creating A Resume
- 10 Tips For Making A Resume (1)
I've been working on my Resume for months now. Here is a summary of what I've learned: 1.
Avoid referring to yourself via 1st person or 3rd person terms. Rather than saying "I started this
job in" just say "Began job in"... Employers expect Resumes to be professional and avoid reference
to oneself; and instead speaking in an impersonal tone that presents
achievements/skills/experience/education without personalization. Avoid words like "I", "my", "he",
"she", etc. Leave out personal pronouns and only use the action words/verbs. This also includes
your Ob...
Making A One Page Does All Website In Phph
- (2)
Hello and Great Day or Night either one. Have you ever been to a site and seen a index page or any
page at all control everything such as index.php?do=home&action=logout something similar to the
above? Well I am going to show you how easy it is to make this all own your own, and only have to
use one web template or design to make it work. Before we get started you need to go ahead and find
the web design that you want to use. After you find the site you want to use go ahead and save
it... and save it like this so we can work together, ok! Note* We are going to ...
Making a java based program
- (3)
Java GUI Making a Little Java Program Sec. 1: Imports and starting it off Sec. 2: Variables Sec.
3: Frame and Stuff Sec. 4: Declaring buttons Sec. 5: Adding buttons Sec. 6: Action Listening Sec. 7:
Using this for a learning experience Section 1 Now, let's think. What imports do we need? We
obviously need GUI imports. We also need the action Listener. So, let's declare this at the very
top: Code: CODE import java.awt.*; import java.awt.event.*; import javax.swing.*; That's
all we need to get all our supplies. Now to start us off. Skip a couple lines ...
Templating System Using Php Includes
- Building a Dynamic site using Includes and flat-files. (13)
Php based Templating System http://jlhaslip.trap17.com/template/index.php The Source Code
for the scripts are included (literally) on the different pages on the Demo, including the Contact /
Email script. The only page not there yet is the Message Script. Maybe tonight I will upload that.
This one uses a little bit of query-string checking to confirm that the contents of the page are
actually available (file_exists())and an allowed page content before serving it up. The
'allowed page content' is done by checking against a flat-file containing an array...
HTML tags and examples
- Condensed form of course from my site... (37)
Well, I decided to try and help out some of the users here who might be unexperienced in HTML, so I
condensed the begginer's HTML course at my website. Here it is... Lesson 1 HTML means Hyper
Text Markup Language. HTML is a very common language used for many websites, is the base for more
complicated and powerful langauges like php, HTML can seem hard, but you will find it is one of the
easiest langauges one can learn. The core of HTML is the tag, a tage is just a set of two
arrows-like brackets created by hitting Shift and the comma key, or Shift and the period...
Making A Dynamic Page On Blogspot
- Using an external server to make your pages hosted on blogspot dynamic (5)
Good morning everyone. Have you ever wondered how to allow your visitors to edit content on your
blog? Like adding a post straight off the page, adding a link, editing your profile etc. This will
be extremely useful if you want your visitors to contribute to your blog besides writing comments or
tagging. 1. Adding a post straight off the page. Go to blogger.com, login, select your blog. Go to
settings -> email. By enabling blog email, you can now add a post by simply sending an email to the
address you specified. The address should look something like: yourusername...
Cpanel Useful Site Management Tools 2.1
- Part 3 of My 7 Part Tutorial (0)
This Tutorial will be divided into 7 different parts, and this is the first part, when i get the
other parts together, i will post the links under here /biggrin.gif" style="vertical-align:middle"
emoid=":D" border="0" alt="biggrin.gif" /> Enjoy. Part 1: E-mail Management Part 2: Useful Site
Management Tools Part 4: Analysis/Log Files Part 5: Advanced Tools Part 6: PreInstalled
Scripts, Extras, and Cpanel Options Part 7: Fantastico Detailed Cpanel Tutorial Part 2.1:
Useful Site Management Tools In this tutorial I will, in detail explain all of th...
Cpanel Useful Site Management Tools
- Part 2 of My 7 Part Tutorial (0)
This Tutorial will be divided into 7 different parts, and this is the first part, when i get the
other parts together, i will post the links under here /biggrin.gif" style="vertical-align:middle"
emoid=":D" border="0" alt="biggrin.gif" /> Enjoy. Part 1: E-mail Management Part 3: Useful Site
Management Tools2.1 Part 4: Analysis/Log Files Part 5: Advanced Tools Part 6: PreInstalled
Scripts, Extras, and Cpanel Options Part 7: Fantastico Detailed Cpanel Tutorial Part 2:
Useful Site Management Tools In this tutorial I will, in detail explain all of t...
Looking for making, popular, id, browsing, site,
|
*RANDOM STUFF*
*SIMILAR VIDEOS*
Searching Video's for making, popular, id, browsing, site,
*MORE FROM TRAP17.COM*
|
advertisement
|
|