i have db table as product_master,in that product master have many products and each product have minimum cost and maximun cost,my doubt is,in ui,i select product in one dropdown text box,dynamically another dropdown text box select that selected product's minimum and maximum cost,how can i do using select query???

Member Avatar for diafol

This is not very clear arun. Please rephrase the question Also show your database table structure and any php code that you've attempted.

   <td>
            <input type="text" onKeyUp="FindProduct(this.value, event);" onblur="ShowPrice();" size="15" name="txtSearchProduct" tabindex="5" value="" placeholder="Search Product" />  
          <select name="lstProductNameN" style="width: 180px;" tabindex="6" onchange="ShowPrice()">
                <?php

                            $sSql="Select product_name, product_id from at_product_master where recstatus = 1";
                    FillListQuery($sSql, $con, "product_name", "product_id", "");
                ?>
            </select>              
        </td>

 <td>
<select name="txtPriceN" style="width: 180px;" tabindex="6">
               <?php

                $sSql="Select Concat(IFNULL(ProductMinCost,''),' | ',IFNULL(ProductMaxCost,'')) as DET,product_id from at_product_master where recstatus=1";
                    FillListQuery($sSql, $con, "DET", "product_id", "");
                ?>
            </select>              

        </td>   

@diafol,can u understand my codings???

Member Avatar for diafol

OK from this, you probably don't get the fact that PHP is a server-side language and that it can't react to browser (user) based events. If you need this type of interactivity you need a "middle man" in the form of javascript to send a request to the server (AJAX) and to wait patiently for a response, which hopefully will contain some nice data to update your dropdowns.

However, this is not obvious from your code as you have a plethora of inline "onXXX" js calls as FindProduct and ShowPrice is lost to us and could in fact be Ajax calls?? Equally, the php function FillListQuery is a black box.

I am assuming that you're using a mysql / maria database.

I asked if you could provide your DB table structure, but you haven't supplied this info. From your SQL statements, I'm assuming that it has the following:

  • product_name
  • product_id
  • recstatus
  • ProductMinCost
  • ProductMaxCost

You seem to be getting the price of a single product_id from the first drop down and then displaying a single price range in the second dropdown. I don't understand it, if this is the case.
Why have a second select dropdown to choose a single item? I could understand a div or p container providing additional info for the product.

If you're downloading all the product_ids and product_names, I'd just download the costs too - store the whole lot in a json object and use javascript to do the additional info provision - no more calls to server after page load.
Just a thought.

commented: Yes, back end, middle and front. +12
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.