Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Pro PHP
|
Pro PHP Advanced PHP coding discussions. Beginning-level questions will be redirected to the Beginning PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 30th, 2007, 09:34 PM
Registered User
 
Join Date: Dec 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Dependent Dropdown php/mysql/java

Hi,

Im kinda new to php/mysql programming and I was hoping I could get some help with this. I am trying to create 2 dependent dropdown menus. gThe first one dictate the content of the second one. I hot the connection right but once the second menu loads I could scroll down the list but nothing it is showing on it. ike i cant see the fonts. I read the page source and it is showing the options on it.
Any help I would greatly appreciate.

Here it is the code:
$category = $item = null; //declare vars

$conn = mysql_connect($server,$user,"");
$db = mysql_select_db('sin',$conn);

if(isset($_GET["category"]) && is_numeric($_GET["category"]))
{
    $category = $_GET["category"];
}

if(isset($_GET["item"]) && is_numeric($_GET["item"]))
{
    $item = $_GET["item"];
}
?>

<script language="JavaScript">

function autoSubmit()
{
    var formObject = document.forms['theForm'];
    formObject.submit();
}

</script>

<form name="theForm" method="get">

    <p>

  </p>
    <table width="200" border="1">
      <tr>
        <td>Select Category</td>
      </tr>
      <tr>
        <td><select name="category" onchange="autoSubmit();">
          <option value="null"></option>
          <option value="199" <?php if($category == 199) echo " selected"; ?>>Hydraulics</option>
          <option value="299" <?php if($category == 299) echo " selected"; ?>>Electronics</option>
        </select></td>
      </tr>
      <tr>
        <td>Select Item</td>
      </tr>
      <tr>
        <td>
          <div align="center" class="style2 style3">
            <select name="item" onchange="autoSubmit();">
              <option value="1">select Here</option>
              <?php

        //POPULATE DROP DOWN MENU WITH COUNTRIES FROM A GIVEN REGION

        $sql = "SELECT cat, desc_p FROM parts WHERE cat <= $category";
        $items = mysql_query($sql,$conn);

        while($row = mysql_fetch_array($items))
        {
            echo ("<option value=\"$row[desc_p]\" " . ($item == $row["desc_p"] ? " selected" : "") . ">$row[dec_p]</option>");
        }

        ?>
            </select>
          </div></td>
      </tr>
    </table>
    <p><br>
    </p>
</form>







Similar Threads
Thread Thread Starter Forum Replies Last Post
Dependent DropDown In DataGrid software_developer_kk ASP.NET 1.0 and 1.1 Professional 3 January 29th, 2007 03:13 AM
begin php & mysql - chapter 12, user_form.php jon_stubber Beginning PHP 1 March 9th, 2006 10:57 AM
Store Items from dropdown menu in mysql database scoobie PHP Databases 0 April 28th, 2005 08:17 AM
Displaying values in dropdown list from mysql db scoobie Beginning PHP 3 January 25th, 2005 12:09 PM
dependent dropdown lists vivshah VS.NET 2002/2003 1 March 29th, 2004 05:25 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.