Google Answers Logo
View Question
 
Q: *********HELP******** HTML PAGE CHANGE AUTO $2.01 ***********HELP*********** ( Answered 5 out of 5 stars,   4 Comments )
Question  
Subject: *********HELP******** HTML PAGE CHANGE AUTO $2.01 ***********HELP***********
Category: Computers > Programming
Asked by: helpandrersearch-ga
List Price: $5.95
Posted: 14 May 2003 06:32 PDT
Expires: 13 Jun 2003 06:32 PDT
Question ID: 203566
How do I make a page change automatically? Like a file named test.html
and it has a script in there for sample and I punch in:
http://www.yourdomain.com/test.html?kep=49k7g57h654gf
and then the page changes??

Request for Question Clarification by sgtcory-ga on 14 May 2003 07:27 PDT
Hello helpandrersearch,

Can you please offer a little more insight? Do you wish to make a page
redirect to another?


Thanks for the clarification -

SgtCory

Clarification of Question by helpandrersearch-ga on 14 May 2003 08:28 PDT
Hi sgtcory-ga,

No, I mean something like punching in the question mark (?) and the
page changing such as http://www.yourdomain.com/test.html?whatever
then the page changes from the regular page. "page changing" means
that the page will display something else than what is in the file
because of the question mark telling to display something else. I
think this requires MySQL. I'm not sure. I've got MySQL. Also I am
using my own server (IIS 5.1) and maybe for ATL Networks (Red Hat
Linux).

helpandrersearch-ga
Thank you

Clarification of Question by helpandrersearch-ga on 15 May 2003 05:52 PDT
sgtcory-ga,
Is there any script I have to put in the SSI file for it to connect to the database?

Request for Question Clarification by sgtcory-ga on 15 May 2003 07:46 PDT
Hello helpandrersearch,

I am certain myself or another researcher will be able to assist you.
You may want to consider opening new questions or reviewing the
question pricing guidelines, as the answers will require more in depth
analysis than your List Price would typically cover.


You can review the pricing guidelines here:

Answers Pricing Guidelines
http://answers.google.com/answers/pricing.html

Request for Question Clarification by errol-ga on 19 May 2003 20:15 PDT
Hi there!

Do you have the use of PHP on your web server?

If so, I would be willing to give you a quick answer to either:
a) set it to include a different page or file depending on the
?variable.
b) set it to select records from the database and include them on the
page.

This would have the effect that you desire of changing content as seen
on so many websites (even Google: www.google.com/search?q=variable).

Kind regards,
errol-ga.

Clarification of Question by helpandrersearch-ga on 20 May 2003 08:23 PDT
Hi, errol-ga
Yes, I have PHP on my server. I also have those other things that may
be required such as CGI. I host with ATLNetworks. (standard plan)
There website is www.atlnetworks.com in case you need to know anything
els (that I may not know such as what I have).

Thanks,
helpandrersearch-ga

Request for Question Clarification by errol-ga on 20 May 2003 08:30 PDT
Thank you for your clarification.

However, I still need to know something.
Do you need to know how to simply display different pages (include
different html content in the current page) by changing the part after
the "?" or is it more complicated than that, maybe with MySQL?

Kind regards,
errol-ga.

Clarification of Question by helpandrersearch-ga on 20 May 2003 08:31 PDT
sgtcory-ga
Do you think $5.95 would be enough for answering this question? By the
way, your document was very good, I learned alot but I don't
understand how the page will know that those values are in MySQL.

helpandrersearch-ga,
Regards

Clarification of Question by helpandrersearch-ga on 20 May 2003 08:36 PDT
errol-ga,
I don't know how to explane this to you,but I think it is just putting
other stuff in 1 document but not having it load the default page when
you just do the page and no question mark (?). Then Ipunch in the
question mark then the page changes when I click Enter. After the
question mark (?) then the page changes with
whatever=trivaquestion122. If this is not enough then please ask
questions such as What version of PHP do you have?

helpandrersearch-ga,
Regards
Answer  
Subject: Re: *********HELP******** HTML PAGE CHANGE AUTO $2.01 ***********HELP**********
Answered By: errol-ga on 20 May 2003 09:47 PDT
Rated:5 out of 5 stars
 
Hello again, Helpandrersearch.


I'll give you two examples, the first with file includes and the
second with the MySQL data inclusion.
I'll try to make it as easy as possible to understand.


Files
------

Contents of "index.php":

<?php
switch ($page) 
{
    case "1":
        include('page1.inc'); 
        break;
    case "2":
        include('page2.inc'); 
        break;
    case "3":
        include('page3.inc'); 
        break;
    default:
        include('default.inc'); 
}
?>

The above code tells the script to load whichever file is determined
by the variable "$page".
For example, to load page 2 (page2.inc) you would write
www.yoursite.com/index.php?page=2

Contents of "default.inc":

<html>
<head>
<title>Default Page</title>
<body>
<h1>Default, this is what people will see if they go straight to
index.php with no ? on the end.</h1>
</body>
</html>

Contents of "page1.inc":

<html>
<head>
<title>Page 1</title>
<body>
<h1>Page 1</h1>
</body>
</html>

This is "page1.inc" which contains basic HTML.
Developers use the ".inc" extension to help them determine which pages
are includes and which are not when viewing the contents of the web
space.
You can include any type of file and use any file extension, for
example page1.html or picture.jpg.

Try using a text editor such as Notepad to copy and paste the above
examples and save them using the correct file extension (index.php,
default.inc, page1.inc and page2.inc etc) to test them on your
webspace.

For more on "case switching" and file includes, visit the following
pages:
http://php.lamphost.net/manual/en/control-structures.switch.php
http://php.lamphost.net/manual/en/function.include.php

MySQL
------

<?php

// Enter your MySQL database information below

$host = "localhost";
$user = "MYSQLUSERNAME";
$pass = "MYSQLPASSWORD";
$db = "MYSQLDATABASENAME (usually username with db on the end)";
$table = "MYSQL TABLE CONTAINING THE DATA THAT YOU WISH TO INCLUDE";

// Connecting to the database

$link = mysql_connect ($host, $user, $pass);
$q = "SELECT * from $table";
$results = mysql_db_query ($db, $q, $link);

// Depending on what the value of $data is ( or
www.yoursite.com/index.php?data= ),
// it will select the corresponding data from the database table that
you specified above.

switch ($data) 
{
    case "1":
	$q = "1";
        echo $results; 
        break;
    case "2":
	$q = "2";
        echo $results; 
        break;
    default:
        echo 'No row specified'; 
}

mysql_close ($link);
?>

To use this, simply use www.yoursite.com/index.php?data= then put
number 1 or 2 on the end.
You can change the variable to whatever you need for your database.
For example, if you had a database with the rows "name" and
"phonenumber" you could use
www.yoursite.com/index.php?data=phonenumber.
There is a lot more that you can do than this, but it does take time
to learn.

For more on MySQL and PHP, view the following sites:
http://hotwired.lycos.com/webmonkey/programming/php/tutorials/tutorial4.html
http://www.mysql.com/articles/ddws/
http://www.freewebmasterhelp.com/tutorials/phpmysql/1
http://www.phpworld.com/articles/2000.02/mysql_000.html

------


I hope this helps you understand it a little more.
Kind regards,
errol-ga


Related Google searches:

"php mysql"
://www.google.co.uk/search?q=php+mysql

"php switch"
://www.google.co.uk/search?q=php+switch

Request for Answer Clarification by helpandrersearch-ga on 06 Sep 2003 12:19 PDT
Hi,
I was going to create a page with this script right now, however I am
asked the following:

Type
Attributes
Null/Not Null
Default
Extra
Primary
Index
Unique
Fulltext.

I am not sure what it should be. Also, what type should it be. The
types I am able to create are:

Default
MyISAM
Heap
Merge
ISAM.

Also, on the field "field", should "page" go there or should "1" go
there? Then, for the string field should "1" or "page" go there?

Also, sorry for the long time it took for me to pay for this answer, I
was on a vacation then when I got back to my home I checked my email
and I received a few of emails from Google Answers regarding the
payment, I know that the vacation was long, sorry about that.

Thank you,
helpandrersearch-ga
helpandrersearch-ga rated this answer:5 out of 5 stars and gave an additional tip of: $3.95
Thank you for the answer errol-ga!! It was very useful. I learned alot from it also!

Comments  
Subject: Re: *********HELP******** HTML PAGE CHANGE AUTO $2.01 ***********HELP***********
From: sgtcory-ga on 14 May 2003 09:33 PDT
 
Hello helpandrersearch,


I believe what you are seeking is a little more in depth than I can
offer for the listing price, as we would have to walk through several
tutorials.

This process takes a little understanding of at least one language(of
choice), but I'll attempt to outline :


Essentially what you would be doing is some server side processing.
MYSQL is simply a database to store your information, although the
variables/strings that you wish to create could be passed in and out
of MYSQL.


You would need to utilize some type of language (PHP, Perl, Java) to
have the variables in the URL parsed or passed through for further
processing. A variable/string in your example could be as simple as
something like this :

http://www.yourdomain.com/test.html?question=whyistheskyblue

The variable would be 'question', and the string value would be
'whyistheskyblue'.

A typical application of this example? We could just say that your
variable question returns a dynamic answer. When a user 'visits' the
above URL, the answer is generated by :

- Your server processing the string - using whatever language you have
chosen
- Pulling the data for the answer you have stored in MYSQL (or any
other DB)
- Displaying the answer for the variable

I hope this helps - and I hope I didn't confuse you ;-) It's a rough
outline, but I wanted to make it easy to understand.

SgtCory
Subject: Re: *********HELP******** HTML PAGE CHANGE AUTO $2.01 ***********HELP***********
From: helpandrersearch-ga on 20 May 2003 08:33 PDT
 
sgtcory-ga,
I give you a 5-star rating.
Subject: Re: *********HELP******** HTML PAGE CHANGE AUTO $2.01 ***********HELP***********
From: sgtcory-ga on 20 May 2003 14:25 PDT
 
Looks like a great answer ;-)


I will help you in the future should you still need it. Thanks for the
great comments.
Subject: Re: *********HELP******** HTML PAGE CHANGE AUTO $2.01 ***********HELP**********
From: errol-ga on 20 May 2003 18:40 PDT
 
Many thanks for your kind generosity Helpandrersearch!

PHP is a wonderful language to learn and also very, very powerful.
It is always my top choice when coding a web site. :)

Regards,
errol-ga.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy