Hi guys,
I am learning PHP. I see some code in some webpage like:
http://www.webmaster-forums.net/member.php?u=10145
or
http://www.webmaster-forums.net/misc.php?do=bbcode
if anybody tell me that what is " ?u=10145 " and how it is used.
Thanks,
Naoshad.
Thanks,
Naoshad
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Try not to become a man of success, but rather try to become a man of value.
Albert Einstein







pitbull82 posted this at 11:27—10th April 2005.
He has: 18 posts
Joined: Apr 2005
It's a variable and its value which helps you to manage your site.
Simple example. Save it as example.php:
<?php
<html>
<head>
</head>
<body>
<!--
Here we have content of the site
-->
if (isset($_GET['where']))
$where=$_GET['where'];
else
$where='';
switch ($where)
{
case 'first':
echo "Here's the content of the first article. (You could use include funcion here)\";
break;
case 'second':
echo \"Here's the content of the second article. (You could use include funcion here)\";
break;
case 'third':
echo \"Here's the content of the third article. (You could use include funcion here)\";
break;
default:
echo \"Here's the main page (or there was bad value of where). (You could use include funcion here)\";
}
<ul>
<li>
<a href=\"example.php?where=first\">First link</a>
</li>
<li>
<a href=\"example.php?where=second\">Second link</a>
</li>
<li>
<a href=\"example.php?where=third\">Third link</a>
</li>
</ul>
</body>
</html>
?>
Hope that's useful for you
http://www.mnabialek.pl | | it.hk.pl
naoshad posted this at 16:57—10th April 2005.
He has: 23 posts
Joined: Feb 2005
it will be very helpful if you ilaborate the code. i mean if you make comments in every line where necessary.
Naoshad
Thanks,
Naoshad
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Try not to become a man of success, but rather try to become a man of value.
Albert Einstein
naoshad posted this at 16:58—10th April 2005.
He has: 23 posts
Joined: Feb 2005
thanks a lot for your reply.
pitbull82 posted this at 17:03—10th April 2005.
He has: 18 posts
Joined: Apr 2005
Well, there's nothing to comment in here. Only switch instruction, $_GET - that's the array which store your variables given via GET method ( example.php?where=first - this is GET method - where will be stored in $_GET['where']), isset - checks if variable exists or not.
That's all. If u don't understand it - sorry, start learning PHP...
http://www.mnabialek.pl | | it.hk.pl
Assassin posted this at 02:17—11th April 2005.
He has: 77 posts
Joined: Apr 2005
This might help you out. This is the source code of the homepage of my website. You can see it in action at http://assassin.cjb.cc
Assassin Band
<?PHP
/* here I'm simply including a CSS file. it's got nothing to do with your question */
include("http://assassin.cjb.cc/assassin.css");
/* Here's where it starts to get interesting. This if then thing tells my page that if there is nothing in the "Query string" which is the ?u=10145 in your question that my variable $Pagename should be set to home */
if($_SERVER['QUERY_STRING']==NULL){
$Pagename=home;
}
// This gets the query string if there is one
else{
/* My URL always comes as http://assassin.cjb.cc?$Pagename=whatever. All I want is the whatever, so first I make an array that contains 2 pieces: 1)http://assassin.cjb.cc?$Pagename= and 2) whatever */
$Query = explode("=", $_SERVER['QUERY_STRING']);
// this sets my variable $Pagename to the whatever that I got before
$Pagename=$Query[1];
} ?>
<?PHP if($Pagename=="home"){ print("
Home
<?PHP if($Pagename=="bios"){ print("
<?PHP if($Pagename=="book"){ print("
<?PHP if($Pagename=="originals"){ print("
Songs
<?PHP if($Pagename=="covers"){ print("
<?PHP if($Pagename=="past"){ print("
<?PHP if($Pagename=="shows"){ print("
<?PHP
/* This sets my page. all of the code above just sets my tabs and my header. this is where the real action is. I have all of my pages set up so that they can be linked to in this matter. */
include("http://www.cjb.cc/members/assassin/" . $Pagename . ".html"); ?>
I really hope this helped. The code can be a little overwhelming at first, but I think you should be able to get it.
Assassin Band Website
naoshad posted this at 04:04—11th April 2005.
He has: 23 posts
Joined: Feb 2005
thank you all.
heartsaffection posted this at 06:46—21st April 2005.
They have: 26 posts
Joined: Apr 2005
Hiya,
I have just answered a question very similar to this in the thread 'Ready to move from html - php site...how?'. Please take a look at that for a VERY simple explanation.
Thanks,
Andy - http://www.heartsaffection.com