30 users online (0 members and 30 guests)  


  Results 1 to 1 of 1

Related

  1. Select Query    Forum: Databases
    Replies: 2
  2. Cannot Select DB using mssql    Forum: PHP Forum
    Replies: 2
  3. I need to wrap a table around my select box    Forum: CGI Perl Forum
    Replies: 0
  4. CSS and select    Forum: CSS Forum
    Replies: 1
  5. links and select box    Forum: CGI Perl Forum
    Replies: 0
  1. #1
    rdub's Avatar
    New User

    Status
    Offline
    Join Date
    Oct 2006
    Posts
    15

    Propogating select box

    This code is working fine for propogating the "select" box with all of the choices from "Category_Listing".

    I would like to be able to fill the select box with Customer whose category is "places to eat" in the "Category_Listing" column.

    This would be on a seperate page.

    Currently working at http://host557.ipowerweb.com/~idyllwil/test_back_members.php

    Here is the current code.

    <?
    // Connect database
    mysql_connect("localhost","*****","*****");
    mysql_select_db("idyllwil_members");

    $select = "--select--";

    // If submitted, check the value of "select". If its not blank value, get the value and put it into $select.
    if(isset($select)&&$select!=""){
    if(!empty($_GET['select'])){ $select = $_GET['select']; }
    }
    ?>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <style type="text/css">
    <!--
    .style1 {
    font-family: Georgia, "Times New Roman", Times, serif;
    font-size: 11px;
    }
    -->
    </style>
    </head>
    <body>
    <form ID="form1" Category Listing"form1" method="get" action="<? echo $PHP_SELF; ?> ">
    Selections :
    <select name="select">
    <option value="">--- Select ---</option>
    <?
    // Get records from database (table "member_list").
    $list=mysql_query("select distinct Category_Listing from member_list order by id asc");

    // Show records by while loop.
    while($row_list=mysql_fetch_assoc($list)){
    ?>
    <option value="<? echo $row_list['Category_Listing']; ?>"
    <? if($row_list['ID']==$select){ echo "selected"; } ?>>
    <? echo $row_list['Category_Listing']; ?></option>
    <?
    // End while loop.
    }
    ?>
    </select>
    <input type="submit" name="Submit" value="Select" />
    </form>
    <hr>
    <p>
    <?
    // If you have selected from list box.
    if(isset($select)&&$select!=""){

    // Get records from database (table "member_list").
    $result=mysql_query("select * from member_list where Category_Listing='$select'");
    while($row=mysql_fetch_assoc($result)) {




    ?>
    </p>
    <table width="250" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
    <td><strong>
    <?

    //if ($row != ""){
    //echo $row;
    //}

    echo $row['Customer']; ?>
    </strong></td>
    </tr>
    <tr>
    <td><? echo $row['Description']; ?></td>
    </tr>
    <tr>
    <td><? echo $row['Phone']; ?></td>
    </tr>
    <tr>
    <td><? echo $row['Fax']; ?></td>
    </tr>
    <tr>
    <td><? echo $row['Email']; ?></td>
    </tr>
    <tr>
    <td><? echo $row['Web_Link']; ?></td>
    </tr>
    </table>
    <p><br>



    <?
    // End While statement
    }
    // End if statement.
    }


    // Close database connection.
    mysql_close();
    ?>
    </p>
    <p><br>
    </p>
    </body>
    </html>
    Last edited by rdub; 11-30-2006 at 01:37 PM.



Tags for this Thread