5 Replies Latest reply on Apr 26, 2010 12:09 PM by programmalicious

    why can't I find the answer to this anywhere?


      Hi, please help a beginner...

      I'm trying to build an online catalog with PHP and MySQL, using Dreamweaver.


      I have a problem with filters... here it is:

      I have some variables... let's take 1 for ex. $manuf in which I want to store the manufacturer (for the notebooks table, like "acer", "alienware" etc.).

      I figured I'll do the filters one of 2 ways:


      1. through dropdown list/menu and I've populated the list with the values "acer" "alienware" etc.

      and in "OnChange" event of the list/menu I want to assign the selected value of the list/menu to the variable $manuf.

      HOW do I do this??? I can't find anything like a property list1.selected for ex. to simply write <?php $manuf = list1.selected ?>

      where list1. should be the name of the list/menu (right?...)



      2. it looks nicer with a SpryMenu.

      So I have a Spry Menu like "Manufacturer" etc.

      And Submenus like "Acer", "Alienware" etc.

      now... when I click the submenu labeled "Acer" I can just do the php $prod = "acer" BUT HOW can I also change the menu's caption to say "Manufacturer - Acer" instead of just "Manufacturer" ??? ('cause I want people to see what filter is applied). Again, I can't find any property like sprymenu1.caption or something like that.




      regarding the list/menu... I can populate it dynamically, from the database... with the values from $manuf field. BUT they repeat, because there are more than 1 "acer" for ex. in the catalog (database). HOW can I dynamically populate the list from the database, without repeating any value???

        • 1. Re: why can't I find the answer to this anywhere?
          Ben M Adobe Community Professional

          For the time being I think I am going to start with just problem 1 because I think as I go through explaining this to you, the answer to #2 will become more clear.


          Javascript is like Actionscript (Flash) and can be executed in runtime meaning that if you execute javascript on a page you can see the results immediately.  PHP, on the other hand, is a preprocessor meaning that the code is executed prior to a page load and cannot be executed in runtime like Javascript can.  Your mix of the two for this instance is really not needed unless you want the form to act dynamically.  Because of this there are 2 ways  to approach the situation:


          1.  If you want to stick with PHP, when you submit the form, the values of the stored will be stored in the global variables ( http://php.net/manual/en/reserved.variables.php ).  Based on the method of your form will depend on how you extract the data.  For instance, if your form method is "POST" and the drop-down field named "manuf" has a value of "Dell", then when you submit the form, the variable $_POST['manuf'] will be equal to "Dell".


          With this example the form has to be submitted because Javascript cannot send commands to PHP once the page has been loaded because the PHP has already been executed.


          2.  This way is a lot more complicated so I won't go into much detail.  But, the Spry Dataset functions are intended for updating data live without the need to submit a form forcing a page refresh for the PHP to execute.  What happens with the Spry dataset is that you store all the information in mySQL and then the Spry Dataset will convert this into XML for you. PHP will be used to run the initial query of your database and depending on the size of your database can be used to filter the data so you do not end up with an extremely large XML file slowing your page load time.  I do have a basic example I did awhile back located here ( http://www.exitplaystation.com/warhawk/trophies.php ).  That used a static XML document at the time.  I do have a more dynamic example.  It was actually done for work, but I might be able to modify it with bogus information and upload it to show you a dynamic version.  In the meantime if you want to see a professional example of this in action:




          FoxSports uses the Spry Dataset sort functions and some extra code for their live NFL draft system.  Refreshes automatically and sorts from the top drop-down menus.  So as you can see all of their data is loaded from their database connection and refreshed in real-time.  This is a very complicated example and requires modifications to the Spry code, but it shows the power of what Spry can do.



          Let me know which way you would prefer to go with this.  Personally I would recommend #1 for starters until you get going and feel more comfortable with PHP and Javascript.  Also if you give more a little more detail on your code I could help you implement it if you are having difficulty understanding.

          • 2. Re: why can't I find the answer to this anywhere?
            MaxCroft Level 1

            Thank you for your help!

            I guess I could go with the submit/post. It certainly gets the job done.


            There's one more thing though... I don't really need to do anything in runtime.

            I don't need to first set all the filters and only then to apply them.

            It's allright to do a reload on the page, I could find the "excuse" to update(reload) the page each time a filter is being modified (a spry menu item clicked). I've seen plenty of online stores for ex. that do that (and yes, it does bug me to not be able to select all the filters first :D).


            So... not beeing absolutely necesarely to happen in runtime, if i am doing a page reload, can I be able somehow to modiffy the spry menu caption through PHP coding? (I'm guessing probably not, since it doesn't actually have a "caption" property)


            Or, if PHP can't get the job done, can I easily (easily meaning few lines of code) do it through Javascript (i'm not going to learn javascript, i'm just willing to learn a minimum to get this done... i hope dreamweaver will do most of the job and just leave a few lines of code up to me like it would do with PHP <?php line1; line2; ?> something like that, just 2-3 lines of code for me to write, no complex functions/declarations and stuff)


            Thanks again!

            • 3. Re: why can't I find the answer to this anywhere?
              Ben M Adobe Community Professional

              Unfortunately I think you are trying to get back to your original post with the Spry Menu Bar updating.  It can update through a Spry Data Set ( http://labs.adobe.com/technologies/spry/samples/menubar/MenuFromNestedData.html ).  However, the instructions for doing advanced things with the Spry functionality is not user friendly and requires you to read through the sample code that Adobe has made.  Hopefully CS5 will bring an update to Spry since it has not been updated since CS3.  Spry is updated separately from DW so if you want to watch for updates bookmark the following site:




              Updating could possibly be done with PHP, but if you are looking for the simplest solution then I would leave the menu as is.  It was not originally intended to work in that fashion the way Adobe designed it.

              • 4. Re: why can't I find the answer to this anywhere?
                MaxCroft Level 1

                sorry... my bad

                i was just thinking of my last post on my way back from work, and i just answered myself...

                if it doesn't need to happen in runtime, i can simply have the menu say whatever value i want at the load of the page


                i'm a rookie, so i think much before realizing some stuff and writting few lines...


                Thanks again for all your help.

                I'm definitely going with the submit/post option. It's not eye candy, but it does the job.


                I'm usually with the eye candy... no matter what I do, i first spend a lot of time to model the body to be graphically rich and eye-catching, very nice to look at, and then a lot later i start to work on the engine (or what's under the hood), while still thinking about how to enhance the visual even more... when it should be the other way around. I would certainly manage to do more and be more efficient.

                • 5. Re: why can't I find the answer to this anywhere?

                  Hey SnakEyez02!


                  Thanks for the compliment re: the foxsports.com NFL Draft Tracker.  I did have to get kind of creative with the filtering and sorting but the framework made it easy to get accurate results.  Spry data handling is really the best out there.