SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict ghostme's Avatar
    Join Date
    Feb 2005
    Posts
    371
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    records search using drop down fields

    Hello good pple of the forum, there are two table in my database. Currently I two different drop down with their being generated from one column each in the tables.

    PHP Code:
    The code is thus:
    <?php
    $db
    =mysql_connect("localhost","root","");
    mysql_select_db("student",$db);
    $result=mysql_query("select CourseTitle from course",$db);
    $sql=mysql_query("select SFname from pupils",$db);

    $name='';
    $sname='';
    while(
    $row=mysql_fetch_array($result))
    {
    extract($row);
    $name.="<option value=\"$CourseTitle\"";
    if(
    $name==$CourseTitle)
    {
    $name.=" selected";
    }
    $name.=">$CourseTitle</option>\r\n";
    }
    while(
    $rows=mysql_fetch_array($sql))
    {
    extract($rows);
    $sname.="<option value=\"$SFname\"";
    if(
    $sname==$SFname)
    {
    $name.=" selected";
    }
    $sname.=">$SFname</option>\r\n";
    }
    ?>
    <form>
    <select>
    <?php echo $name?>
    </select>
    <br>
    <select>
    <?php echo $sname?>
    </select>
    </form>

  2. #2
    SitePoint Addict melchiorus's Avatar
    Join Date
    Jun 2004
    Location
    Indiana
    Posts
    283
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is there a question in there I am missing? What is it exactly you need help with?
    -Melchior (Stephen Craton)

  3. #3
    SitePoint Zealot Quadzoola's Avatar
    Join Date
    Nov 2004
    Location
    Canada
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What's the question?

    *Edit* Mel beat me to it.
    Jeff Busby

  4. #4
    SitePoint Addict ghostme's Avatar
    Join Date
    Feb 2005
    Posts
    371
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    sorry pple now my is on the form handle page where do i pass a variable that will referenced both select drop down menu
    currently i can do for just one
    my code:
    PHP Code:
    $select=(mysql_query("select age,Slame FROM course where Sfname LIKE '%" $_GET['Sfname'] . "%'" 
    i am not getting any result with my current lines of codes. i know i am making a mistake.

  5. #5
    $this->toCD-R(LP); vinyl-junkie's Avatar
    Join Date
    Dec 2003
    Location
    Federal Way, Washington (USA)
    Posts
    1,524
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Your syntax is wrong for the statement you quoted. Try this instead:

    Code:
    $select=mysql_query("select age,Slame FROM course where Sfname LIKE '%" . $_GET['Sfname'] . "%'") ;
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more
    Showcase your music collection on the Web


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
  •