NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page ?f=49

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 09-14-2005, 02:00 PM THREAD STARTER               #1 (permalink)
Senior Member
Join Date: May 2005
Location: Ontario Canada
Posts: 3,088
unknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to behold
 


Diabetes

?f=49


Hey
I have seen this in alot of websites..


How do ppl make Different pages in 1 PHP file

and then link them like this

CURRENTPAGE.PHP?do=something
or
currentpage.php?f=blah

can any1 help me on that

basically i am making a website with Game cheats..and so on and I Need a way of adding ALL THE ALPHATIC pages in 1 FILE

so at the top it says CHEATS: A B C ........... Z

and i dont want to make seprate FILES for each of the alphate but instead i just want it in 1 FILE but when some1 clicks on A ...i only want it to show the content of A in the content box instead of other stuff.... {HINT: NOT BOOKMARK TECHN.}
????: NamePros.com http://www.namepros.com/programming/123730-f-49-a.html

so if some1 clicks on A it redirects to

cheats.php?f=a

if some1 clicks on C it redirects to

cheats.php?f=c

and a way to add the CONTENT in "f=a" and stuff so it only SHOWS That when some1 clicks on "A"..

I hope u know what i am talking about
unknowngiver is offline  
Old 09-14-2005, 02:06 PM   #2 (permalink)
DNOA Member
Join Date: May 2004
Posts: 5,040
mholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant future
 


Autism Marrow Donor Program 9/11/01 :: Never Forget Multiple Sclerosis Adoption Alzheimer's Lou Gehrig's Disease (ALS)
Hey unknowngiver,

In the URL, the question mark means that everything after that is recognized as data for scripting languages (not HTML).
????: NamePros.com http://www.namepros.com/showthread.php?t=123730

So, for example...

page.php?f=12

If that page appeared in a webpage link, it would send the variable "f" with a value of 12 over to page.php.

Multiple variables...

page.php?f=12&a=17

This means it sends "f" and "a" to page.php with the associated values.

As for multiple pages in 1 file, they just write a PHP script that calls include files or header() redirects to another page based on the information in that variable.

See what I mean?
mholt is offline  
Old 09-14-2005, 05:20 PM THREAD STARTER               #3 (permalink)
Senior Member
Join Date: May 2005
Location: Ontario Canada
Posts: 3,088
unknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to behold
 


Diabetes
no its not tht



<?php
if($action=="contact_us"){
$img="images/message.gif";
}else{
????: NamePros.com http://www.namepros.com/showthread.php?t=123730
$img="images/welcome.gif";
}
?>

just an example i could find

Basicaly what i want is tht

When some1 clicks 'A'

everything else from the content box gets hidden and only the stuff for A shows

etc

so it oculd be something like tht?


<?php
if($action=="A"){
$content="Content for A";
}else{
$content="Main content";
}
?>

and then do it for B in the same page etc...
unknowngiver is offline  
Old 09-14-2005, 05:55 PM   #4 (permalink)
Senior Member
 
Eric's Avatar
Join Date: Mar 2005
Posts: 4,948
Eric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatness
 

Member of the Month
MOTM September 2005
Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Animal Rescue Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Baby Health Cancer Alzheimer's Protect Our Planet Cancer Survivorship SIDS Child Abuse Diabetes Protect Our Planet Multiple Sclerosis Autism Adoption Special Olympics
Yea something like that I suppose,

PHP Code:
<a href='script.php?action=1'>A</a>
<a href='script.php?action=2'>B</a>
<a href='script.php?action=3'>C</a>
<?php
if($action == 1)
{
echo 
"Content for A.";
}
if(
$action == 2)
{
echo 
"Content for B.";
}
if(
$action == 3)
????: NamePros.com http://www.namepros.com/showthread.php?t=123730
{
echo 
"Content for C.";
}
?>
Heh,
Eric is offline  
Old 09-14-2005, 06:03 PM THREAD STARTER               #5 (permalink)
Senior Member
Join Date: May 2005
Location: Ontario Canada
Posts: 3,088
unknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to behold
 


Diabetes
Yes but i only want the content to appear in the content box....but i think wid this code.. the nav bar and other stuff on the page will also disapear?
unknowngiver is offline  
Old 09-14-2005, 06:41 PM   #6 (permalink)
tgo
NamePros Regular
Join Date: Aug 2005
Posts: 315
tgo is on a distinguished road
 



Ok well since you want it all in one page, usualy this is done with a database.

You see what you see with the

yourpage.php?yourvariable=x

This takes the value of yourvariable (x) and looks in a database to match that with a field to find the row of information that you need for that page with that variable.

Example
http://famousqt.com/profile.asp?celeb=1 - Jessica Alba
http://famousqt.com/profile.asp?celeb=2 - Jennifer Love Hewitt
Its the same code, just pulls different information depending on what the celeb variable is.

This example takes the celeb variable, looks in the database and finds the info for that number, then pulls the information to display it on screen.

My database has this info

CelebId (primary key, unique)
CelebName
CelebBiography
etc.

In the url
http://famousqt.com/profile.asp?celeb=1
????: NamePros.com http://www.namepros.com/showthread.php?t=123730
I just bring up the database record for the CelebId that matches "1" and I can then read all information in the database for that celebrity, like their name, or biography.

Hope this helps.
tgo is offline  
Old 09-14-2005, 07:36 PM THREAD STARTER               #7 (permalink)
Senior Member
Join Date: May 2005
Location: Ontario Canada
Posts: 3,088
unknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to behold
 


Diabetes
Okay since you are getting into databases..can you explain it as i was going to make a website with games cheats..and description of it
????: NamePros.com http://www.namepros.com/showthread.php?t=123730

So how am i going to do that

Should i have 2 tables for it then?

1 that will display the LINKS to games starting with A B C - Z

and the other one that will have the information {cheat..game name..description}

Can you please explain how am i suppose to do it {i will donate some NP$ if it really helps}

Basically i want it all done in 1 page

So when some1 clicks on "A"
it shows the stuff from the TABLE "A" and then if some1 selects a game starting with "A" lets say "AIRPLANE W.E" then he/she will see a page witth tht games cheats and description..?
unknowngiver is offline  
Old 09-14-2005, 08:49 PM   #8 (permalink)
tgo
NamePros Regular
Join Date: Aug 2005
Posts: 315
tgo is on a distinguished road
 



What your asking for will need 1 table and 2 pages.

Table
Games
-Fields
--GameId (primary Key, auto increment)
--GameName
--GameShortDescription
--GameDescription
--GameReview
--GameCheats
--Other unique to the game fields

Page 1 -gamelist.asp
-objective - display all game names, and short description that start with a certain letter with links to them all above.
Look Like
A B C ..... X Y Z
ace - Short Description of the game....
arobatics - Short Description of the game....
astronaught - Short Description of the game....
etc...
--Code Needed--
Read the url, see if it has a variable (perhaps you name it letter)
-your url should look like gameslist.asp?letter=A

If there is no letter variable you can display the "A" record on default
????: NamePros.com http://www.namepros.com/showthread.php?t=123730
-do this by using SQL and select only the records where the GameName starts with a "A"
-MYSQL code to do this(I didnt test this)
Code:
SELECT GameId, GameName, GameShortDescription FROM games where GameName LIKE 'a%'
Then you loop through all the games that start with A


If there is a letter variable you check what it is and use that in your my SQL instead of the default
So if they press the "H" it will display the ones that start with H.
ASP way, I dont know PHP that well
Code:
mySQL="SELECT GameId, GameName, GameShortDescription FROM games where GameName LIKE  '" & letter & "%'"
Then you loop through all the games that start with the variable letter

** when looping use the gameId field from the database in the url of the links to the games
** All links look like "gamedata.asp?game=<%=objRs("GameId")%>
** this ensures you can find on the next page what game to display the info for.

Page 2 - gamedata.asp
-objective - display the game name, Description, Cheats
Read the url and find what the game variable is.
Take that variable, and do a SQL statement like below
Code:
mySql="SELECT GameId, GameName, GameDescription, GameCheats FROM games where GameId=" & game
Since GameId is unique, it will only return 1 record and you can display that info for that game.

Thats the way I would do it, hope this helps.
tgo is offline  
Old 09-14-2005, 09:20 PM THREAD STARTER               #9 (permalink)
Senior Member
Join Date: May 2005
Location: Ontario Canada
Posts: 3,088
unknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to behold
 


Diabetes
sorry can u do it in PHP instead of ASP
unknowngiver is offline  
Old 09-14-2005, 09:26 PM   #10 (permalink)
tgo
NamePros Regular
Join Date: Aug 2005
Posts: 315
tgo is on a distinguished road
 



Originally Posted by unknowngiver
sorry can u do it in PHP instead of ASP
Nope but its the same concept.
tgo is offline  
Old 09-15-2005, 02:48 AM   #11 (permalink)
NamePros Regular
 
dkin69's Avatar
Join Date: May 2005
Posts: 358
dkin69 has a spectacular aura aboutdkin69 has a spectacular aura about
 



I created my site this way using files and switchs like so

function page1()
{
code
}

switch ("$page")
{
case "abc":
page1();
break;

}

then your url would be .php?page=abc
dkin69 is offline  
Old 09-15-2005, 06:46 AM   #12 (permalink)
SQLdumpster.com
 
Encenta.com's Avatar
Join Date: Jun 2005
Location: West Sussex, UK
Posts: 573
Encenta.com has a spectacular aura aboutEncenta.com has a spectacular aura about
 




Please show some gratitude, these people are trying to help you out. I think SecondVersion's post may be of use to you. If you are worried that your navbar and head will not be displayed, code them into different php files and "include" them like so:

PHP Code:
if($action == 1)
????: NamePros.com http://www.namepros.com/showthread.php?t=123730
{
include (
"head.php");
include (
"nav.php");

echo 
"Content for A.";

include (
"foot.php");

__________________
Encenta - Amazon Associates CMS
Encenta.com is offline  
Old 09-15-2005, 09:47 AM THREAD STARTER               #13 (permalink)
Senior Member
Join Date: May 2005
Location: Ontario Canada
Posts: 3,088
unknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to behold
 


Diabetes
Yea but again it will display the nav and header in tht order right?

I have included the Nav bar and so on in different places...and i only want to change the CONTENT area for A-Z
unknowngiver is offline  
Old 09-15-2005, 10:20 AM   #14 (permalink)
NamePros Regular
Join Date: Aug 2005
Posts: 214
slantednet is on a distinguished road
 



You keep saying "change the content area" but your taking big steps. You're looking at developing this site, break it down into baby steps.

The baby steps your looking at isn't just "change the content area", you're actually going to call back the same page and pass it some variables. With those variables in the page, your going to requery the information you need from the table, "rebuild" the page, and display it to the user.

In the user's mind, you're only "changing the content area" but from a development point of view you've got a few more steps to go through to accomplish this.

I recommend googling for a couple of PHP tutorials, get yourself a PHP IDE (not necessary, but helpful, and there are many free ones out there (PHP Designer 2005 is looking real nice)) and start giving it a shot. What your looking to do is rather simple, and a great introduction project to developing dynamic sites with PHP.

When you get stuck on a part, come back here and post in the programming forum. There are many talented people here that are willing to offer a helping hand to those that help themselves, or cough up some duckies for the assistance.
????: NamePros.com http://www.namepros.com/showthread.php?t=123730

But here, to get you started, just design your page in HTML, you don't have to start with generating the whole thing in PHP. Lay it out exactly how you want it, and where your navbar is with the "A B C D E" make the links link back to the page. So if your working on listing.php, put all html in there, and for link A, use the url "listing.php?list=a", for B use "listing.php?list=b", etc.

Then, down where you want the content area for your page, do this (this is pseudo code, it won't work as typed, you want to learn, do some research)

PHP Code:
if $list is not set {
    
// generate whatever you want to display for when they come without 
    // specifying a letter
} else {
   if 
$list is not numeric and length of $list is equal to 1 
 
//only one letter in list
        // setup your query
        
$query "select blah blah blah from blahtable where title like '$list%'"
        
// execute the query
        
$res do_query($query);
        
// set a var to hold your display
        
$pageinfo ""
        
// then loop through the resulting rows
        
while($row fetch_result_array($res)) {
              
// display content for each resulting row from the database
              
$pageinfo .= "<tr><td>" $row['title'] . "</td></tr>";
        }
   }
}

// kick the resulting "content area" back to the user
echo $pageinfo;

// then continue on with the rest of your html 
????: NamePros.com http://www.namepros.com/showthread.php?t=123730
Really, it's that simple. Of course, there are grander ways to do this, but this will get you started with the basics.

Good luck,
Mike
__________________
OnlineGames.net
Last edited by slantednet; 09-15-2005 at 10:32 AM.
slantednet is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Liquid Web Smart Servers  
All times are GMT -7. The time now is 05:05 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger