| |||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | #1 (permalink) |
| Senior Member | ?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.} 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 :P |
| |
| | #2 (permalink) |
| DNOA Member | Hey unknowngiver, In the URL, the question mark means that everything after that is recognized as data for scripting languages (not HTML). 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?
__________________ codeboards A high-quality community of programmers -- Join today and post! We want new members! |
| |
| | #3 (permalink) |
| Senior Member | no its not tht <?php if($action=="contact_us"){ $img="images/message.gif"; }else{ $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... |
| |
| | #4 (permalink) |
| NPQ's PA, Slave, and On Call Coder Technical Services | Yea something like that I suppose, PHP Code:
__________________ |
| |
| | #6 (permalink) |
| NamePros Regular | 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 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.
__________________ |
| |
| | #7 (permalink) |
| Senior Member | 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 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..? |
| |
| | #8 (permalink) |
| NamePros Regular | 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 -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%' 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 & "%'" ** 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 Thats the way I would do it, hope this helps.
__________________ |
| |
| | #12 (permalink) |
| SQLdumpster.com | 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:
__________________ !!!!!!! see something you like? Accepting offers for great affiliate websites !!!!!!! Free Databases for your Website | All Things Playstation 3 Website Design Books | Music While You Work? | Computer Gadgets |
| |
| | #14 (permalink) |
| NamePros Regular | 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. 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: Good luck, Mike
__________________ OnlineGames.net Last edited by slantednet; 09-15-2005 at 09:32 AM. |
| |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |