Jump to content

Linking


Viper23

Recommended Posts

I have seen websites that use php or other languages. Some of these links have the page title and ? then rest of link.EX: http://www.domain.com/about.php?who_we_are How would you go about doing something like that?Better EX: http://www.campbellstreet.org/app/w_page.p...mp;type=section

Link to comment
Share on other sites

Check the PHP forms section of the tutorial on the w3schools site, or also read the sticky thread in the PHP forum about PHP tips.
I checked the PHP tips. My question is now. How do you use the $_GET with <a href=""></a>?
Link to comment
Share on other sites

ok, lets say you have a link that looks like this<a href="yourPage.php?something=some_value">Click me</a>now, on yourPage.php, in the $_GET array, there should be an index called something, which will have the value of some_value. you call it like this:echo $_GET['something'];

Link to comment
Share on other sites

ok, lets say you have a link that looks like this<a href="yourPage.php?something=some_value">Click me</a>now, on yourPage.php, in the $_GET array, there should be an index called something, which will have the value of some_value. you call it like this:echo $_GET['something'];
That didn't really help me. I tried it and didn't work.I'm wanting it to be like this.designing.php?logo=quoteIs there a way that you can show me exactly how to do this?
Link to comment
Share on other sites

The tutorial spells it out....oh, for the love of god:Any HTML file:<a href="designing.php?logo=quote">Click me</a>designing.php in the same folder

<?phpecho $_GET['logo'];?>

Change the value after the "=" sign, and you'll see that in the output.You can have multiple query string name=value pairs, separated by "&". The server could be adjusted to separate them with other characters as well (but "&" is the default).So, for example:<a href="designing.php?logo=quote&MyParam=MyValue">Click me</a>designing.php

<?phpecho $_GET['logo'], ' ', $_GET['MyParam'];?>

Link to comment
Share on other sites

Ok, now how do you go about making the page to be clicked on and saving it.I know you can't save a file with ? in it. So how would I go about it?Sorry not really good at php.

Link to comment
Share on other sites

Sorry not really good at php.
No offense, but we can tell. lol.What do you mean by saving it? saving it to a server, saving it to your computer, saving it to some place in taiwan? Saving it to a database? file on your server? what?
Link to comment
Share on other sites

I know you can't save a file with ? in it. So how would I go about it?
You don't save the file with a question mark in it. You save the file like normal, for example index.php, and then in the link you write whatever information you want to go on it. The web browser doesn't look for a file with a question mark in it, it looks for whatever file comes before the question mark and sends the rest of the information to the file.
Link to comment
Share on other sites

Ok. Say we create a file, called index.php (without any question marks). Inside this file we have the content

<?php	echo $_GET['string'];?>

Now, we have another file called link.html in the same folder. Inside we have

<html><body><a href="index.php?string=hello">Click</a></body></html>

Now, when someone clicks on that link, he will be transported to index.php. index.php will read the URL, and see that string has been to equated to "hello". So, it will echo "hello". You would not actually "save" the ?string=hello part in your filename because that would be pointless - you might as well just write

<?php	echo "hello";?>

The ? part of the URL is only added when the file is actually called. Think of them like arguments for web pages :)

Link to comment
Share on other sites

Ok, I think the problem was, because I was trying to run the page without uploading to a web host first.Would this cause the page not to load right?

Link to comment
Share on other sites

In order to run PHP you need to have it installed. If you want to test it on your local computer you will need to install a web server and the PHP software, or you can also use a package that includes both of them. If a web server has it installed already then you can just upload your files and run them online.

Link to comment
Share on other sites

I tried it on my web host and still didn't work.Do I need to have the file after the ?id= to be .php or .html, or does it matter?

Link to comment
Share on other sites

WAW,that was very insightfull.Viper, i am horrible at php, javascript, xml, etc etc etc,I do this stuff for fun, believe it or not.The guys on this website are FANTASTIC, and the tutorials are EXCELLENT, check them out , you may not understand it right away but they would atleast help you ask the question right.Good luck

Link to comment
Share on other sites

OK, if I make a page called gallery and want to have like 3 pages. I know the first page will be called gallery.php when I save it, but when I make the other pages and save them. How and what will I call them?I know the link would be like this, gallery.php for the main like and want the link to other pages look like this, gallery.php?id=2

Link to comment
Share on other sites

assuming that you have pictures in a sql table or something of the like, the first page would be gallery.php like you said, then you could have a 'next' link that linked to 'gallery.php?id=2', then somewhere on the gallery page you would have something likeif ($_GET['id'] == 2) { $picture_start = 15 // (or however many pictures you want per page)}same for 3, except double the abovethen when you are creating the php to display the photos (from the sound of it you are a long way off from that) it would use the variable $picture_start to decide which picture from the sql table it should display first and go from there

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...