0

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???

2
Contributors
4
Replies
33
Views
4 Weeks
Discussion Span
Last Post by diafol
0

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

0
   <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>   
1

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.

Edited by diafol

Votes + Comments
Yes, back end, middle and front.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.