We hope you enjoy your visit.

You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
  • Pages:
  • 1
  • 3
Php site.com?site
Topic Started: May 5 2005, 10:24 PM (1,084 Views)
Das
Member Avatar
Smells of rich mahogany
[ *  *  *  *  *  *  * ]
This is probably pretty noobish, but how do you get http://www.url.com/index.php?something ? I don't get the .php?something is that like a mask of a new page, or is that some Sql thing?
Offline Profile Quote Post Goto Top
 
Seth
Member Avatar
I has a pony
[ *  *  *  *  *  *  *  *  * ]
It's found in the $_GET[] superglobal array.

http://sethkinast.com/blog/?q=200 gives me $_GET['q'] == 200, which IdioQuote then steals and grabs Quote #200 from the database.
Offline Profile Quote Post Goto Top
 
Das
Member Avatar
Smells of rich mahogany
[ *  *  *  *  *  *  * ]
Seth
May 5, 2005 08:24 PM
It's found in the $_GET[] superglobal array.

http://sethkinast.com/blog/?q=200 gives me $_GET['q'] == 200, which IdioQuote then steals and grabs Quote #200 from the database.

You get a round of applause. You managed to make me think I understood, then make me confunsed, then make me hit my head aginst the wall, then make me make me ask why I can't understand, and finally you mad me ask what the mullet $_get[] is. Not only did you make me do all that you made me do it in about a 35 second time span. :P

Can you expain what $_get[] is, and how it is used? And if you can don't link to php.net that is sometimes confusing.
Offline Profile Quote Post Goto Top
 
Seth
Member Avatar
I has a pony
[ *  *  *  *  *  *  *  *  * ]
$_GET[] is an array. It contains all the variables in the URL like ?q=200.
Offline Profile Quote Post Goto Top
 
Das
Member Avatar
Smells of rich mahogany
[ *  *  *  *  *  *  * ]
How is it used in PHP? Does it actually create a new subpage? Can you give a coded example?
Offline Profile Quote Post Goto Top
 
Seth
Member Avatar
I has a pony
[ *  *  *  *  *  *  *  *  * ]
http://sethkinast.com/blog/?q=33

=======

$qid = $_GET['q'];
$quote = get_quote($qid);
echo($quote); // echoes Quote #33
Offline Profile Quote Post Goto Top
 
Das
Member Avatar
Smells of rich mahogany
[ *  *  *  *  *  *  * ]
I guess knowing what quotes were might help hint hint. Is $_Get[] kinnda like taking bob.php and turning it in to index.php?bob ?
Offline Profile Quote Post Goto Top
 
Seth
Member Avatar
I has a pony
[ *  *  *  *  *  *  *  *  * ]
Nooooooooooooooooooooooooooooooooooooooooooo. It's NOT some sort of way to make new pages. It's just a variable. I set it to 33.

*thinks*

The quotes are the Quote of the Moment on my blog.
Offline Profile Quote Post Goto Top
 
Das
Member Avatar
Smells of rich mahogany
[ *  *  *  *  *  *  * ]
I r teh dummy. Lets see if I can make things simple. How does ?showtopic=137803&st=0&#entry3123828 show this page? Is this topic it's own file? If I am getting on your o so wise nerves a link would work.
Offline Profile Quote Post Goto Top
 
Seth
Member Avatar
I has a pony
[ *  *  *  *  *  *  *  *  * ]
That creates the variable $_GET['showtopic'] == 137803.

IPB then says, get the topic with ID 137803 from the database. Plug it into the templates.
Offline Profile Quote Post Goto Top
 
kingy
1 in 10 people understands binary, the other 1 doesn't
[ *  *  *  *  *  * ]
Simple example for you

www.page.com/index.php?who=Kingy
Code:
 

<?php
echo $_GET['who'];
?>
says hello!

That would make it say Name says hello

You could change the name to anything and it would still work

Its a way of setting a variable into a value.
Offline Profile Quote Post Goto Top
 
Gornakle
Member
[ *  *  *  *  * ]
Basically, it lets the user set a few variables. For instance:

Code:
 
<?php

$topic_id = 20; // ID of the topic we want to view.
$query = mysql_query("SELECT * FROM topics WHERE id={$topic_id}");

// ... You get the rest


That would always display the topic with ID 20. That's no good, because now you could only view one topic. So, you let the user chose the topic ID:

Code:
 
<?php

$topic_id = $_GET['id'];

// ..etc.


Now, file.php?id=21 would set $topic_id to 21 and we'd get the topic we'd want. Yay. ^_^
Offline Profile Quote Post Goto Top
 
Dennis
Member
[ *  *  *  *  *  *  * ]
GET natively is a method of passing form information from one page to another. Using a GET kind of tricks PHP into thinking that you filled out a form, and it uses that to decide what to put on the page.

Like this:

URL: index.php?act=home

Quote:
 
</head>
<body>
  <?php
  $act = $_GET['act'];
  if($act == 'home');
  {
  echo 'Welcome to the home page');
  }
  $act = $_GET['act'];
  {
  echo 'This is the second page';
  }
</body>
</html>


The home page would be active now, since the "act" variable is set to home.
Offline Profile Quote Post Goto Top
 
Rory
i;m a mess
[ *  *  *  *  *  *  * ]
you have your

$_GET['act'] = $act;

the wrong way round. It should be:

$act = $_GET['act'];
Offline Profile Quote Post Goto Top
 
Dennis
Member
[ *  *  *  *  *  *  * ]
Oops. Sorry. It's fixed now.
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
Go to Next Page
« Previous Topic · Technology Chat · Next Topic »
Add Reply
  • Pages:
  • 1
  • 3