SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2000
    Location
    Turnersvill, NJ
    Posts
    35
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello,

    I have succesfully created a php page that will list the titles of songs from a table called LYRICS.

    I have a field called TITLE, which is the title
    and a field called WORDS, which are the words to the song.

    When somebody selects a song, I would like the page to refresh, with the same listbox up top and following it, would be the lyrics to the song they selected....

    I have attached the code, Please don't laugh too much. I am very new to PHP! What the code does now is creat the list box and pass the title to a var called $aid....

    Thank you VERY much for your help in advance!!! This PHP/mySQL is making things very easy for my web site, but this one is making me lose some sleep!

    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>

    <body bgcolor="#FFFFFF">
    <?php
    $dbcnx = @mysql_connect("*****", "*****", "*****");
    if (!$dbcnx) {
    echo( "<P>Unable to connect</P>" );
    exit();
    }
    if (! @mysql_select_db("*******") ) {
    echo ("<P>Unable to locate the database.</P>");
    exit();
    }


    $title = mysql_query("SELECT title FROM lyrics");
    $words = mysql_query("SELECT words FROM lyrics");
    ?>

    <FORM ACTION="<?php echo($PHP_SELF); ?>" METHOD=get>
    <P>Please select the songBR>


    <SELECT NAME="aid" SIZE=5>
    <OPTION SELECTED VALUE="">Select One
    <OPTION VALUE="">---------
    <?php
    while ($song = mysql_fetch_array($title)) {
    $aname = $song["title"];
    $aword = $song["words"];
    echo("<OPTION VALUE='$aname'>$aname\n");
    }
    ?>
    </SELECT></P>
    <P><INPUT TYPE=SUBMIT NAME="submit" VALUE="SUBMIT"></P>
    </FORM>


    ?>

    </body>


    </html>

    <Edited by klubrant on 12-15-2000 at 04:26 AM>

  2. #2
    SitePoint Enthusiast
    Join Date
    Jun 2000
    Location
    Turnersvill, NJ
    Posts
    35
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    got it figured out!
    (sorry about the wasted post)

    -Keith

  3. #3
    SitePoint Wizard silver trophy Karl's Avatar
    Join Date
    Jul 1999
    Location
    Derbyshire, UK
    Posts
    4,411
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you post the solution to your problem we won't hunt you down There may be others in a similar situation as you.
    Karl Austin :: Profile :: KDA Web Services Ltd.
    Business Web Hosting :: Managed Dedicated Hosting
    Call 0800 542 9764 today and ask how we can help your business grow.

  4. #4
    SitePoint Enthusiast
    Join Date
    Oct 2000
    Posts
    89
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I suggest you in your database use id field as primary key and auto increment. It will speed up your scripts and make everything easy. What i mean is:

    id smallint unsigned primary key auto_increment
    title varchar(250);
    lyric text;

    and
    <option value="id goes here"> title goes here

    IMHO
    Great Dane
    Gokhan ARLI


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
  •