'Nother Question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
SilverMist
Forum Commoner
Posts: 65
Joined: Tue Mar 02, 2004 2:06 pm
Location: Canada
Contact:

'Nother Question

Post by SilverMist »

Okie, here's my problemo. I can make a page like page.php?pid=1 but here is what I need: page.php?pid=1&name=Page&cat=3 because I am making a lyric website, so I'm going to make it so when someone clicks on "Keith, Toby" and his CD Shock N' Y'All, then song Whiskey Girl, the page has to be k.php?name=keithtoby&cd=shocknyall&song=whiskeygirl. Okay? Please help :-)
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: 'Nother Question

Post by Weirdan »

SilverMist wrote:Okay?
Ok. What's the question? :D
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

You just create the links to do so:

Code: Select all

<a href="page.php?artist=keith-toby">Keith, Toby</a>

  <a href="page.php?artist=keith-toby&album=Shock-n-yall">Shock N All</a>

   <a href="page.php?artist=keith-toby&album=Shock-n-yall&song=whiskeygirl">Whiskeygirl</a>
Can all be done one a single page that just looks to see if there is an artist/album/song in the url, and if there is show the correect listing.
User avatar
SilverMist
Forum Commoner
Posts: 65
Joined: Tue Mar 02, 2004 2:06 pm
Location: Canada
Contact:

Post by SilverMist »

Yes BUT, I need the code so that I can place all the page content. Like I need the code so that when they click Shock N' Y'all, I need to put a list of all the songs on that disk, then, when selected, can proceed to the song page. If you need more info, just ask, I'm not that good at explaining things. :oops:
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

Code: Select all

if(isset($_GET['artist'])){
   //show albums
}else if(isset($_GET['album'])){
   //show songs
}else if(isset($_GET['song'])){
   //show lyrics
}else{
   //show artists
}
If this is going to be a large database of lyrics then your best off using ID's for artists/albums/songs so that you can link to a direct song or album as there are many that have the same name. So all you need to do really is have a database like:

Code: Select all

id
type #will be either artist/album/song
value
parent
Then just first of all show a list of all artists - where type = artist. Then when the user clicks on that - say the id is '777' you list all type = album where parent = '777', then when the user clicks on an album - the id = '12345', do the same process again and again until you get to the song, and grab the lyrics.
User avatar
SilverMist
Forum Commoner
Posts: 65
Joined: Tue Mar 02, 2004 2:06 pm
Location: Canada
Contact:

Post by SilverMist »

Heh, thank you!! But there is still a problem :( Here is my code:

Code: Select all

<?php
{
echo "Hello there. This is me, testing a page!";
}
if(isset($_GET['artist'])){ 
   //show albums 
echo "I guess this is the artists page!!";
}else if(isset($_GET['album'])){ 
   //show songs 
echo "Weeee 'nother page!";
}else if(isset($_GET['song'])){ 
   //show lyrics 
echo "Wee yet another page!";
}else{ 
   //show artists 
} 
?>
So, when I go to the page, I get the whole "Hello there. This is me, testing a page!" thing, which is wonderful :-) But here's the problem. When I go page.php?artists I get "Hello there. This is me, testing a page!I guess this is the artist's page!" which, as you can prolly tell, is not what I want :(
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

Yes as you echo it at the top and its not in any conditional statement - hense it is run everytime the page is called. You can add it to the final else to show that the page is working fine - as something will always be echoed on the page no matter what data is in the url.
User avatar
maqmus
Forum Commoner
Posts: 30
Joined: Mon Mar 08, 2004 1:10 pm

Post by maqmus »

Code: Select all

<?php 
if(isset($_GET['artist'])){ 
   //show albums 
echo "I guess this is the artists page!!"; 
}else if(isset($_GET['album'])){ 
   //show songs 
echo "Weeee 'nother page!"; 
}else if(isset($_GET['song'])){ 
   //show lyrics 
echo "Wee yet another page!"; 
}else{ 
   echo "Hello there. This is me, testing a page!"; 
} 
?>
In this case if $_GET is empty you'l get "Hello there...."
User avatar
SilverMist
Forum Commoner
Posts: 65
Joined: Tue Mar 02, 2004 2:06 pm
Location: Canada
Contact:

Post by SilverMist »

Well I tried all this and I'm getting an error on line 4.
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

well... waht is line 4?? We can't just guess at what you have. It might help if you just post what you currently have ...
Post Reply