Ask a Question related to Macromedia ColdFusion, Design and Development.

  1. #1

    Default Inventory Tracker

    Hi

    First thanks for your help
    Here's my problem

    I want to ouput a title (model number) with a table under wich will contain
    the dealers who have that model in stock.


    In my database i have a table that contain the models and a table that
    contains the dealers with the model in stock
    I'm not sure how to make the output

    Any help would be appreciated!

    Thanks!

    Tim



    <cfquery datasource="database" name="getmodel">
    SELECT model from testmodel
    ORDER BY model asc
    </cfquery>

    <cfquery datasource="digiouiz-data" name="getdealer">
    SELECT * from inventory WHERE model='#getmodel.model#'
    ORDER BY dealerid asc
    </cfquery>

    timhockey Guest

  2. Similar Questions and Discussions

    1. Inventory db query
      Hi I have to keep a running total of parts on hand (widgets) before ordering from the wholesaler, then do another query if all are sold out on...
    2. Displaying Inventory
      I have a database containing over 700 items. I can display the data based on catagory such as bronze, ivory, paintings, etc.. I was wondering if...
    3. Hit Tracker Script
      Hey all... Here's a short little script I wrote to track visitors to our website. http://www.cabarettheatre.org/hittracker.phpx Just save...
    4. Inventory list
      Howdy folks. How to manage an inventory list with two records that have the same catalogue number? There's a inventory file with following...
    5. Inventory Databases
      I am wondering what advice people have about the following: Our company needs to keep track of purchased inventory (when purchased, how much,...
  3. #2

    Default Re: Inventory Tracker

    Can you post your output code? Also, you may be able to combine the two queries into one.
    mxstu Guest

  4. #3

    Default Re: Inventory Tracker

    Here's the code

    Thanks!




    <cfquery datasource="database" name="getmodel">
    SELECT model from testmodel
    ORDER BY model asc
    </cfquery>

    <cfquery datasource="database" name="getdealer">
    SELECT * from lamtracinventory WHERE model='#getmodel.model#'
    ORDER BY dealerid asc
    </cfquery>


    <cfoutput query="getdealer" group="model">#model#
    serie(#getdealer.recordcount# available)</cfoutput>


    <cfoutput query="getdealer">
    #dealerid </cfoutput>

    timhockey Guest

  5. #4

    Default Re: Inventory Tracker

    Does [lamtracinventory] contain one row per model/dealer or does it contain multiple rows per model/dealer?


    mxstu Guest

  6. #5

    Default Re: Inventory Tracker

    each row contain the model number and the dealer that have it in stock
    so let's say 1 dealer have 4 models 1200
    it will be 4 rows
    timhockey Guest

  7. #6

    Default Re: Inventory Tracker

    Because you want to display the total number in stock before you display the
    dealer details, you will probably need to nest a query within the output loop.
    Otherwise, you could just calculate the total as you looped and display the
    number at the end of each model section.





    <!--- gets all models, even if nothing is in stock --->
    <cfquery datasource="myYourDSN" name="getdealer">
    SELECT m.Model, i.DealerID, COUNT(DealerID) As NumberInStock
    FROM TestModel m LEFT JOIN lamtracinventory i ON m.Model = i.Model
    GROUP BY m.Model, i.DealerID
    ORDER BY m.Model, i.DealerID
    </cfquery>

    <cfoutput query="getDealer" group="model">
    <!--- use query of query to get total for current model -->
    <cfquery dbType="query" name="getAvailable">
    SELECT SUM(NumberInStock) AS NumberAvailable
    FROM getDealer
    WHERE Model = '#getDealer.Model#'
    </cfquery>
    <b>#model# series (#getAvailable.NumberAvailable#)</b> <br>
    <cfoutput>
    #dealerid# Amount(#NumberInStock#) <br>
    </cfoutput>
    </cfoutput>

    mxstu Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139