-
I have been reading all the tuts and came up with a database and a couple of pages. I know I am getting close to the answer, but just can't seem to get it. 2 pages - one to show lyric titles and then click on the title to show the lyric. the echo?id just won't cross over to the view lyric page, keeps showing the first listing no matter which lyric you click on. here are the pages:
<HEAD>
<TITLE>Select your Lyrics</TITLE>
</HEAD>
<BODY>
<H1>Select Your Lyrics</H1>
<P>
<UL>
<?php
include("connectjunk.inc");
while ($lyric = mysql_fetch_array($lyrics)) {
$id = $lyric["ID"];
$name = $lyric["lyrictitle"];
$lyrictext = $lyric["Text"];
echo("<LI><A HREF='viewlyric.php3?id=$id'>$name</A> ");
}
?>
</UL>
<P ALIGN=CENTER><A HREF="admin.htm">Return to Front Page</A></P>
</BODY>
</HTML>
<HTML>
<HEAD>
<TITLE>Select your Lyrics</TITLE>
</HEAD>
<BODY>
<H1>Select Your Lyrics</H1>
<P>
<UL>
<?php
include("connectjunk.inc");
$lyric = mysql_fetch_array($lyrics);
$id = $lyric["ID"];
$lyrictitle = $lyric["lyrictitle"];
$lyrictext = $lyric["Text"];
echo("<LI>$lyrictitle "."<LI>$lyrictext");
?>
</UL>
</BODY>
</HTML>
I can't even figure out which page it is that has the problem.
------------------
Hutnut
www.roserobin.com
-
Are you using the same query for both pages. It seems that your query id $lyrics is the same on both pages. Is it possible that you are still select ing all records from the db and that would be why you are always getting the first record. You would need to modify the second pages query to select where id = $id
-
I tried that and now it says error in SQL syntax. This is how i redid the pages, seems i left out some info the first time.
<HEAD>
<TITLE>Select your Lyrics</TITLE>
</HEAD>
<BODY>
<H1>Select Your Lyrics</H1>
<P>
<UL>
<?php
include("connectjunk");
$lyrics = mysql_query("SELECT lyrictitle, Text FROM Lyrics");
if (!$lyrics) {
echo("<P>Error retrieving lyric from database!<BR>".
"Error: " . mysql_error());
exit();
}
while ($lyric = mysql_fetch_array($lyrics)) {
$id = $lyric["ID"];
$name = $lyric["lyrictitle"];
$lyrictext = $lyric["Text"];
echo("<LI><A HREF='viewlyric.php3?id=$id'>$name</A> ");
}
?>
</UL>
</BODY>
</HTML>
<HTML>
<HEAD>
<TITLE>Select your Lyrics</TITLE>
</HEAD>
<BODY>
<H1>Select Your Lyrics</H1>
<P>
<UL>
<?php
include("connectjunk");
$lyrics = mysql_query("SELECT lyrictitle, Text FROM Lyrics WHERE id=$id");
if (!$lyrics) {
echo("<P>Error retrieving lyric from database!<BR>".
"Error: " . mysql_error());
exit();
}
$lyric = mysql_fetch_array($lyrics);
$id = $lyric["ID"];
$lyrictitle = $lyric["lyrictitle"];
$lyrictext = $lyric["Text"];
echo("<LI>$lyrictitle "."<LI>$lyrictext");
?>
</UL>
</BODY>
</HTML>
I really appreciate your taking the time to help me with this, I am really new at all this http://www.SitePoint.com/forums/smile.gif
------------------
Hutnut
www.roserobin.com
-
Maybe
$lyrics = mysql_query("SELECT lyrictitle, Text FROM Lyrics WHERE id = '$id'");
Although I am not sure if that is your problem
-
Thanks I tried that too and still no luck. It shows the bullets on the viewlist page but no lyrics or lyric titles. At least now it no longer picks up just the first lyric and puts it on every page. Its odd but when I click on a lyric title and it takes me to the lyric page there is no ID# in the title bar. Somehow it is still not picking up the ID. Thanks for your help :-)