Jul 20, 2008

Making The Popular Id Browsing For Your Site.

Free Web Hosting, No Ads > CONTRIBUTE > Tutorials
Pages: 1, 2

free web hosting

Making The Popular Id Browsing For Your Site.

friiks
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 tongue.gif
$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 tongue.gif)

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
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. smile.gif

Very nice example, and I know everybody on this forum will agree when they get on to see it. biggrin.gif

Reply

Imtay22
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
Show me the code you're using ,please!

Reply

matak
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
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
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
Wow, I never knew that..
But anyways I've been always using it this way AND it has always worked..

Reply

friiks
Woah, I had a typo in my code tongue.gif
Corrected it, thanks to matak for pointing it out smile.gif

Reply

street
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

Latest Entries

Mariana
Yay, that was very helpful..

Thanks =3

Reply

jlhaslip
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
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
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 ) smile.gif
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
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 smile.gif

Thanks to all trap17 coders!
matak

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Pages: 1, 2
Similar Topics

Keywords : making, popular, id, browsing, site,

  1. Can't Login To Any Software On My Site
    anyone know how to fix? (3)
  2. Need Help: Problem Seeing My Site
    maybe i screwed up? (3)
    I just got my account activated yesterday. so i logged in thru optional
    http://www.qupis.com/client and started setting up my site thru there. But the other links in the
    activated email don't work. ex: http://crazxbox.qupis.com:2082/ I'm' using Firefox 3.
    is that the problem? i don't have IE. " or did I totally mess up my install?" Plus i'm not
    familiar with this mysql 4.1.22, i'm using 5.0.27 is there much of a difference? it says i dont
    have a valid user in phpMyAdmin. Any ways, site http://crazxbox.qupis.com is not working yet.
    I ....
  3. I Need Help With Setting Up My Site, Made Using Java
    any help would be appreciated (5)
    I just got web hosting approved and I want to host the site I created using Struts framework.
    I'm a complete newb when it comes to web hosting, so I need a little help. Is there a tutorial
    that covers this subject? I apologize in advance if this question was already answered, but
    I've been unable to find the answer anywhere. One thing I have to note is that I need to know
    absolute address of the uploaded files in order for my application to work. Is this even allowed?
    Any help with hosting of Java applications will be appreciated.....
  4. Database Or Pdf
    Best way to list books on my site (1)
    Hi all, I am not sure if this is the right place to post but I'm sure you'll tell
    me if it's not. My problem is this: I have a website where I sell books and it's one of
    those simpleton sites where I don't need to know code, I just click icons etc Anyway, I can
    upload images to the server and need to have them in different resolutions and link from a thumbnail
    to the larger picture. What I am trying to say is I have about 6000 books to display on my
    website which is impractical as it takes me about 10 mins to load 1 copy. What is the ....
  5. Free Web Hosting Application [screened] [approved]
    by miikerocks: request for site (PLEASE READ) (6)
    PRESENT CREDITS : Forum Username : miikerocks Email Address: mike_simpson_@hotmail.com My
    Desired Trap17 SUBdomain Name is: www.FreeLoads.org Introduce Yourself: Your hobbies, interests,
    talents, etc. Let the forum know you better. • For hobbies I like to be nice to people,
    well help people out. I like to go on the computer, and one of the things I LOVE is to make
    websites. Ever since grade 3 I have been searching and searching for a way to make a .com for free,
    now I find you guys. THANK YOU SOOOO MUCH!!! I have talents and interests in sport....
  6. Best Browser To Desighn Your Site To
    not much of a question but more like a statement (9)
    well since i started web desighning i've always used internet explore (why?) well when i first
    tried FF2, i wasn't a "web-designer" then so i didn't care much about css and htlm stuff, i
    din't like it and one of the reason was beacause a couple of the sites i visited wasnt firefox
    compatible. but anyways recently i was desighning a site for this community. so like two weeks ago i
    downloaded FF3 for testing purposes. in IE the site looked great but what i found was that in
    firefox the site was horible, as bad as they could come. so since firefox was better....
  7. Can We Host Games With Webhosting This Site Provides?
    Uhm yea I was wondering (1)
    Well, yea the topic name pretty much explains it all. Does this webhosting service let you host
    games such as mafia games and script? Because I need to know! Thanks all!....
  8. Making My Own Browser
    Uhm...need a name (6)
    I am currently developing my own Web Browser and I need a name for it /biggrin.gif"
    style="vertical-align:middle" emoid=":D" border="0" alt="biggrin.gif" /> So if you got any good
    ideas please do post them /biggrin.gif" style="vertical-align:middle" emoid=":D" border="0"
    alt="biggrin.gif" />....
  9. US Court Rules That Google Must Divulge All Youtube Users' Browsing Habits
    yes, *every* user (12)
    As part of their battle with Google, a US court has ruled that Google must hand over the viewing
    habits of every user of YouTube to Viacom. This will include the log-in ID of users, IP addresses
    and video-clip details. Whilst the two companies involved are based in the USA, it is believed that
    details of users from all over the world will be divulged. Considering that there are over 83
    million videos on YouTube and about 500,000 users, I wish the person in charge of sifting through
    this information "good luck". Whilst some would call this one of the greatest invasions ....
  10. No Site Access
    (4)
    It was working the day before yesterday and then it started giving me error messages about not being
    able to access the site. I can't access cpanel either. Neither page ever loads. I don't
    have this problem with any other internet pages, just my site stuff on Trap17. My site's at
    www.jzambrano.trap17.com btw. This is one of the few times I'll need it up for sure so I'd
    appreciate if the issue can get fixed in the near future. ....
  11. Can't Access My Site An Cpanel
    already did some sugested things (4)
    I still can't get to my website and cpanel, Tings I did: requested xisto to unblock my ip
    cleaned my cache/cookies Did this with both IE and FF When I am @ my dads house he can acces my
    website. So I guess it is still an ip problem. I did read some posts but couldn't find a
    solution. Thx in advance,....
  12. Recommended List Of Money Making Sites
    A list of 10 sites from which easy money can be made (0)
    I just want to let everyone know I have updated my list of money making websites and in my opinion
    the 10 listed are the most reliable and honest money making sites that are free to join available.
    Please review this blog and let me know what you think http://makeeasymoney247.blogspot.com ....
  13. Please Can You Review My Blog
    List of recommended sites for making money online (3)
    I am currently in the process of constructing a list of the best sites through which to make money
    online and would like people to take a look at the sites I have added so far. I am obviously still a
    long way of completing it but just wondering whether people think it is a good site / idea
    http://makeeasymoney247.blogspot.com Also if you have not yet signed up to ClixSense I would
    highly recommend it. You can join for free but you are better of paying the small $10 yearly
    membership fee as this will bring you a ton more paid adverts - more than any other site I ....
  14. Great Weather Site
    Cool weather Site (7)
    I found this weather site a few days ago and wow. Has some very clear chase cams.
    Serverstudios.com ....
  15. Need A Name For A Hosting Site
    (2)
    Ok so i'm thinking about setting up a paid and free hosting site with computing host resaller
    plan. but i'm having no luck coming up with a name for the site, evey thing i have tryed it
    taken arleady. so i was wonder if i could get some help with picking a name? so dose any body have
    any ideas? I dont wont it to be one of those super long domain names. Thanks....
  16. Review My Site
    Review my site please (18)
    Hello. I am new here to trap17.com and would really like some input on my site. Echo Of Thunder
    Made using Dream Weaver and note pad. Planning on a better forum and chat page as time goes by.
    This is just a little hobby that I have. "weather" and I hope that you all here at trap17 will take
    a look see, and tell me what you all think. ....
  17. Cool Site To Learn Languages
    Learn to speak in Native accent (4)
    http://www.livemocha.com/ Discovered this site months before. And also I took some classes. I
    should say this is really cool one. Try it. Learn new languages in a social way with LiveMocha.
    Livemocha is the first-of-its-kind online language-learning community. With fun and interactive
    lessons that move at the right pace for you. You can access their team of passionate language tutors
    and start track your progress to reach your goals. Learn, practice, and share. Learn these
    languages: English, French, Hindi, German, Spanish and Mandarin Chinese, among other....
  18. Where Am I Making Mistake
    (9)
    hello i have just started to learn java by myself and i am stuck here with this example i want to
    show a file in console please tell me where am i making mistake. i am getting erroe variable fin
    maight not be initialised here is the code CODE /** Display a text file To use this
    program,specify the name of file that you want to see */ import java.io.*; class showfile {
        public static void main(String args[])throws IOException     {         int i;
            FileInputStream fin;         try             {             BufferedReader br=new....
  19. Books?!
    Web-Site? (7)
    I am the active student of Amrican University of Dubai (AUD). Basically, I' tired of buying new
    books in the UNI's book store whcih will last only for 3 months. Anybody knows where I may get
    them online like in PDF format.....
  20. Making Money From Home
    (13)
    .................................
  21. Php Word Filter
    Have you accidently sworn on your site? Or do you want to keep visitor (7)
    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", "....
  22. Real Paying Site
    Easy and quick (7)
    That site really pays and I have recieved my first payment of 10 dollars. This is really easy not
    much of a big minimum payout and if you want you too can make money by just going here and signing
    up http://adbux.org If you want please do add me as a referrer as zak92 Thank you.....
  23. Runescape 2 Private Server Guide: Part 1
    making a private server (16)
    According to RuneScape TOS, as long as your private server does not connect/interfere with the
    actual server this 3rd party software is not breaking the real RuneScape TOS. Please use this
    information accordingly. If any RuneScape representative feels that this post is against your TOS,
    please contact Trap17 admins via PM or email. Thank you. This is part 1, focused on making a
    private server and such, if you would like, i will post more on customization in other parts.
    Overview: This guide will explain the basics for building your very own rs private server&....
  24. What Are The Steps To Making A Website?
    (15)
    what are some steps to making a website? im doing a project and i need like 5-7, but id ont know
    waht to put. ....
  25. I Hate Site Builders.
    Mainly things like piczo and freewebs. (38)
    Loads of people i know, who have very little HTML knowledge, use Piczo . And now, anyone with one
    of these sites, think they have the best websites ever! All it usually is pictures and text
    randomly thrown on a page, with very-hard-to-navigate links. Freewebs is basically the same. I'm
    not sure about my space, I think it uses HTML, but I hate myspace websites. Anyways, back on the
    point, does anyone else know people who use piczo and think they are the best website builders in
    the world? I tried to teach one how to HTML, got stuck on tags /dry.gif" style="ve....
  26. How To Save *.swf From A Web Site?
    freeware or shareware... (29)
    Greetings, Does anyone know how to grab *.SWF file from web? I've found one software named
    LIATRO SWF DECODER.. anyone have tried it? Is it good? Thanks /biggrin.gif' border='0'
    style='vertical-align:middle' alt='biggrin.gif' /> ....
  27. The Funniest Websites On The Net
    Suggest The Funniest Site On The Net (11)
    I Am Going To Start Of This Topic By Suggesting miniclip.com (Games Site) ....
  28. Best Rpg Maker Site Ever
    (1)
    hey yall if you all into rm2k/3/xp what is your favorite site ever mine well is mine because im very
    good at the program and I make tons and tons of tutorials for the systems but ruby coding is da
    hardest waits of my time. So whats your favourite!....
  29. The Sims 2 Bodyshop
    Making clothes for your sims... (35)
    Hiiiiii Any one playing The Sims 2 must have heard from Bodyshop, or is even very handy with it
    and makes his own clothes to use in the game...!! Well Those people I'd like to ask
    about some tip or tricks, because, I tried making clothes, and were pretty on the good way so far,
    but I just kinda have the feeling I dont know all the tricks yet!! Anybody who is familiar
    with this program can leave some tips/tricks, also for others who want to create great clothes for
    their sims???? Thanksss so very much, I have this outfit in my head, but have no ide....
  30. Im Making A Mmorpg >>
    Have a read... (11)
    can you give your ideas for my new game. if you want to help me even more then send me a private
    message Thanks Tyjotr __________________________________________________ HybridHero - the new 3d
    MMORPG (coming soon)....

    1. Looking for making, popular, id, browsing, site,

Searching Video's for making, popular, id, browsing, site,
Similar
Can't
Login To Any
Software On
My Site -
anyone know
how to fix?
Need Help:
Problem
Seeing My
Site - maybe
i screwed
up?
I Need Help
With Setting
Up My Site,
Made Using
Java - any
help would
be
appreciated
Database Or
Pdf - Best
way to list
books on my
site
Free Web
Hosting
Application
[screened]
[approved] -
by
miikerocks:
request for
site (PLEASE
READ)
Best Browser
To Desighn
Your Site To
- not much
of a
question but
more like a
statement
Can We Host
Games With
Webhosting
This Site
Provides? -
Uhm yea I
was
wondering
Making My
Own Browser
- Uhm...need
a name
US Court
Rules That
Google Must
Divulge All
Youtube
Users'
Browsing
Habits -
yes, *every*
user
No Site
Access
Can't
Access My
Site An
Cpanel -
already did
some
sugested
things
Recommended
List Of
Money Making
Sites - A
list of 10
sites from
which easy
money can be
made
Please Can
You Review
My Blog -
List of
recommended
sites for
making money
online
Great
Weather Site
- Cool
weather Site
Need A Name
For A
Hosting Site
Review My
Site -
Review my
site please
Cool Site To
Learn
Languages -
Learn to
speak in
Native
accent
Where Am I
Making
Mistake
Books?!
- Web-Site?
Making Money
From Home
Php Word
Filter -
Have you
accidently
sworn on
your site?
Or do you
want to keep
visitor
Real Paying
Site - Easy
and quick
Runescape 2
Private
Server
Guide: Part
1 - making a
private
server
What Are The
Steps To
Making A
Website?
I Hate Site
Builders. -
Mainly
things like
piczo and
freewebs.
How To Save
*.swf From A
Web Site? -
freeware or
shareware...
The Funniest
Websites On
The Net -
Suggest The
Funniest
Site On The
Net
Best Rpg
Maker Site
Ever
The Sims 2
Bodyshop -
Making
clothes for
your sims...
Im Making A
Mmorpg
>> -
Have a
read...
advertisement



Making The Popular Id Browsing For Your Site.



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE