SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Aug 2000
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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

  3. #3
    SitePoint Member
    Join Date
    Aug 2000
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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



    ------------------
    Hutnut
    www.roserobin.com

  4. #4
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Maybe
    $lyrics = mysql_query("SELECT lyrictitle, Text FROM Lyrics WHERE id = '$id'");

    Although I am not sure if that is your problem

  5. #5
    SitePoint Member
    Join Date
    Aug 2000
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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 :-)


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •