SitePoint Sponsor |
|
User Tag List
Results 1 to 9 of 9
-
Oct 13, 2003, 05:46 #1
- Join Date
- May 2003
- Location
- Barrow
- Posts
- 342
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
links like lyrics.php?id=Song&1&Lyrics
how would u make one page
lyrics.php
but iff a user clicked the link 'Song 1 Lyrics'
Song 1 Lyrics
Song 2 Lyrics
Song 3 Lyrics
i would want it to open
lyrics.php
but get the Song 1 lyrics Automatically So I Dont Have to Make Each Page By hand.
so a link like lyrics.php?id=Song&1&Lyrics
anyone shed some light?
-
Oct 13, 2003, 06:07 #2
- Join Date
- Oct 2001
- Posts
- 2,686
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi.
I'm not sure if totally understand you question.You don't give much information about how you want it to work.
Anyway, here is what I've come up with based on what you said. I'm assuming you're getting the lyrics from a database.PHP Code:// lyrics.php
error_reporting(E_ALL);
// All songs kept in an array
$songs = array('Song 1 Lyrics', 'Song 2 Lyrics', 'Song 3 Lyrics');
// Printing out a link for every song
foreach($songs AS $song) {
echo '<a href="' . $_SERVER['PHP_SELF'] . '?id=' . urlencode($song) . '">Song 1 Lyrics</a><br />';
}
// Getting the lyrics for a song based on what link is clicked.
if(isset($_GET['id']) && in_array($_GET['id'], $songs)) {
$id = urldecode($_GET['id']);
$query = "SELECT lyrics FROM table WHERE id=$id";
// query db and view result
}
-Helge
-
Oct 13, 2003, 06:14 #3
- Join Date
- May 2003
- Location
- Barrow
- Posts
- 342
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
thanks ill have a try when i finish this script im doin ;P
-
Oct 13, 2003, 08:58 #4
- Join Date
- May 2003
- Location
- Barrow
- Posts
- 342
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Your script is working nearly
im just wondering how to out put the lyrics
on the page i want.
i tried this but dosnt seem to work
PHP Code:<?php
if(isset($_GET['song']) && in_array($_GET['song'], $songs)) {
$song = urldecode($_GET['song']);
$query = "SELECT lyrics FROM audio WHERE song='$song'";
$result = mysql_query($query);
$numofrows = mysql_num_rows($result);
while($row = mysql_fetch_array($result)) {
print'
<tr>
<td class="mainindex">'.$row["lyrics"].'</td>
</tr>';
}
}
?>
-
Oct 13, 2003, 09:03 #5
- Join Date
- Oct 2001
- Posts
- 2,686
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi,
TryPHP Code:if(isset($_GET['song']) && in_array($_GET['song'], $songs)) {
$song = urldecode($_GET['song']);
$query = "SELECT lyrics FROM audio WHERE song='$song'";
$result = mysql_query($query) or die(mysql_error());
$numofrows = mysql_num_rows($result) or die(mysql_error());
if($numofrows > 0) {
while($row = mysql_fetch_array($result)) {
print '<tr><td class="mainindex">';
print $row['lyrics'];
print '</td></tr>';
}
} else {
print 'No lyrics found.';
}
}
HTH
-Helge
-
Oct 13, 2003, 09:13 #6
- Join Date
- May 2003
- Location
- Barrow
- Posts
- 342
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
get no error messages at all, but still nothingworks.
if u wanna see yourself
http://www.zenolith.co.uk/audio.php
only crimson ghosti s the song with lyrics in the db so far. try it
-
Oct 13, 2003, 09:19 #7
- Join Date
- Oct 2001
- Posts
- 2,686
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi.
I get this errormessage from you siteWarning: Wrong datatype for second argument in call to in_array in /home/virtual/site21/fst/var/www/html/lyrics.php on line 20
You have the 'id' in your url (http://www.zenolith.co.uk/lyrics.php?id=Crimson+Ghost) but you use $_GET['song'] in your script. You need to be consistent. Use either id or song.
-Helge
-
Oct 13, 2003, 09:29 #8
- Join Date
- May 2003
- Location
- Barrow
- Posts
- 342
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
PHP Code:<?php
$query = "SELECT * FROM audio ORDER BY type DESC LIMIT 0,50";
$result = mysql_query($query);
$numofrows = mysql_num_rows($result);
while($row = mysql_fetch_array($result)) {
print'
<tr>
<td class="sched" align="center"> : </td>
<td class="mainindex" align="center">'.$row["song"].'</td>
<td class="mainindex" align="center">'.$row["type"].'</td>';
$songs = array("".$row['song']."");
foreach($songs AS $song) {
print'
<td class="mainindex" align="center"><a href="lyrics.php?song='.urlencode($song).'">Lyrics</a></td>
</tr>';
}
}
?>
PHP Code:<?php
if(isset($_GET['song']) && in_array($_GET['song'], $song)) {
$id = urldecode($_GET['song']);
$query = ("SELECT lyrics FROM audio WHERE id='$id'") or die(mysql_error());
$result = mysql_query($query);
$numofrows = mysql_num_rows($result);
if($numofrows > 0) {
while($row = mysql_fetch_array($result)) {
print '
<tr>
<td class="mainindex">'.$row["lyrics"].'</td>
</tr>';
}
} else {
print 'No lyrics found.';
}
}
?>?
-
Oct 13, 2003, 09:47 #9
- Join Date
- May 2003
- Location
- Barrow
- Posts
- 342
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
yay nm it works now
thanks helge
Bookmarks