Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Think you best use option value $rows['Key'] in first dropdown menu and add an jQuery selector that takes the selected value and gets te corresponding contracts for that key.</p> <p>Should be something like this..</p> <p>PHP CODE</p> <pre><code>$query = "SELECT Key, Short FROM product WHERE Active = 1 OR Short LIKE 'Blue%'"; $run = mysql_query($query) or die(mysql_error()); echo 'Product: &lt;br /&gt;'; ?&gt; &lt;select id="select2" name="select2"&gt; &lt;?php echo "&lt;option selected='selected'&gt;-Select product-&lt;/option&gt;"; while($rows = mysql_fetch_assoc($run)) { echo "&lt;option value='".$rows['Key']."'&gt;".$rows['Short']."&lt;/option&gt;"; } ?&gt; &lt;/select&gt; </code></pre> <p>jQUERY CODE</p> <pre><code>$("select#select2").change(function(){ $.ajax({ type: "GET", url: "URL_TO_GET_CONTRACTS_FOR_KEY", data: "selected_key=" + $(this).val(), success: function(result) { $("select#NEWSELECT").html(result); } }); }); </code></pre> <p>Explanation: URL_TO_GET_CONTRACTS_FOR_KEY is an url to a PHP file you have to write. In that file you have access to $_GET['selected_key'], use that value to get the contracts for that key. In that file you should echo the "" tags for the second select. Like this:</p> <pre><code>&lt;?php ## URL_TO_GET_CONTRACTS_FOR_KEY ## $selectedKey = $_GET['selected_key']; $query = .. $run = .. while($row = mysql_fetch_assoc($run)) { echo "&lt;option value='..'&gt;..&lt;/option&gt;"; } ?&gt; </code></pre> <p>NEWSELECT should be replaced by the id of the select where the returned options should be placed in.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload