Calculations from MySQL

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • Rob (SA)
    Lieutenant Colonel

    • Nov 2006
    • 586

    Calculations from MySQL

    Hi folks,

    I have managed to get information into tables in MySQL.

    I know need to do certain thisgs and am in request of help.
    1. I want to type a number into a cell and have it stored in a table (MySQL)
    2. There are 18 such numbers inntiallly which have to be added together to give a total and this toal is to appear on the page that is being veiwed as well as stored in the table.
    this might seem like a simple task but my experiance has shown that it is often the small things that take the most time.

    I look forward to your replies and interaction
    Kind Regards
    Rob
    www.gnjgf.co.za
    www.oryan-projects.com
  • Rob (SA)
    Lieutenant Colonel

    • Nov 2006
    • 586

    #2
    Re: Calculations from MySQL

    Hi,

    I can probaly better explain this by looking at page www.gnjgf.co.za/score.html

    This calculation might be also best done using a from rather than building it from scratch.

    All advice would be welcome
    Kind Regards
    Rob
    www.gnjgf.co.za
    www.oryan-projects.com

    Comment

    • navaldesign
      General & Forum Moderator

      • Oct 2005
      • 12080

      #3
      Re: Calculations from MySQL

      You will need to write a specific Javascript for this. Javascript may be even more difficult than php as it is harder to debug.
      Navaldesign
      Logger Lite: Low Cost, Customizable, multifeatured Login script
      Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
      DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
      Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

      Comment

      • Rob (SA)
        Lieutenant Colonel

        • Nov 2006
        • 586

        #4
        Re: Calculations from MySQL

        Hi George,

        As usual always first to answer.

        It seems like one step forward ten steps back.

        Do you have any suggestions where I can find any examples - I have googled till my eyes are now square in search.

        Examples give me an idea wher eI can start playing and learning with it
        Kind Regards
        Rob
        www.gnjgf.co.za
        www.oryan-projects.com

        Comment

        • Rob (SA)
          Lieutenant Colonel

          • Nov 2006
          • 586

          #5
          Re: Calculations from MySQL

          Hi George,

          I thought of another method -maybe this could work.

          Create the blocks in a room to receive the inputs - then submit to a table.

          In the table do something like this:

          <? $db = mysql_connect('localhost', 'username', 'password');

          mysql_select_db('database_name');

          $query = 'select * from this_table';
          $query2 = 'select SUM(titles) AS qsum from this_table';
          $result = mysql_query($query);
          $result2 = mysql_query($query2);
          $num = mysql_num_rows($result);

          $row = mysql_fetch_array($result2);

          // echo '<strong>'.$num.'</strong>';

          echo '<p>Here are your results: ';

          echo '<strong>'.$row['qsum'].'</strong>'; ?>


          Except that this php would be a little more involved in calculating the totals.

          This information could then also be added to the same table.

          Once this process is complete it can be displayed in html on another page showing the results retreived from the table.

          I hope this makes sense to you and look forward to reply
          Kind Regards
          Rob
          www.gnjgf.co.za
          www.oryan-projects.com

          Comment

          • navaldesign
            General & Forum Moderator

            • Oct 2005
            • 12080

            #6
            Re: Calculations from MySQL

            There are different ways of doing it. If you don't mind having separate pages you can easily do it with PHP.
            PHI is certainly easier.
            Navaldesign
            Logger Lite: Low Cost, Customizable, multifeatured Login script
            Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
            DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
            Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

            Comment

            • Rob (SA)
              Lieutenant Colonel

              • Nov 2006
              • 586

              #7
              Re: Calculations from MySQL

              Hi George,

              My thoughts exactly.

              I thought of splitting the screen.

              One side showing the inputs and the opposite side reflecting the results.

              You guys are the experts and would be able to best advise.

              I am currently trying to have a look at doing it with ABVFP - to create the first form but cant remebr the login details.

              I hope you can help in this regard as well.

              Thanks again for all your help George - I appreciate it
              Kind Regards
              Rob
              www.gnjgf.co.za
              www.oryan-projects.com

              Comment

              • Rob (SA)
                Lieutenant Colonel

                • Nov 2006
                • 586

                #8
                Re: Calculations from MySQL

                Hi George,

                I can post an example of where I want to go an dthis can be seen at http://uploads.saga.co.za/rankings/rateindx.htm

                Is it possible to populate the combobox's with information from MySQl tables?
                Kind Regards
                Rob
                www.gnjgf.co.za
                www.oryan-projects.com

                Comment

                • navaldesign
                  General & Forum Moderator

                  • Oct 2005
                  • 12080

                  #9
                  Re: Calculations from MySQL

                  Sure you can populate the comboboxes with values taken from the database. Before i can give you any code i need to know if youuse BV for the visuals, or you hand code them.
                  Navaldesign
                  Logger Lite: Low Cost, Customizable, multifeatured Login script
                  Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
                  DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
                  Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

                  Comment

                  • Rob (SA)
                    Lieutenant Colonel

                    • Nov 2006
                    • 586

                    #10
                    Re: Calculations from MySQL

                    Hi George,

                    Thanks for the replies.

                    Three things:
                    1. This will be my first BV forms as you did the previous two.
                    2. Suggestions in this regard would be welcome
                    3. Please give me some guides as to how I can populate the comboboxs form MySql tables?
                    Kind Regards
                    Rob
                    www.gnjgf.co.za
                    www.oryan-projects.com

                    Comment

                    • Watdaflip
                      Major General

                      • Sep 2005
                      • 2116

                      #11
                      Re: Calculations from MySQL

                      $query = mysql_query('query string');
                      echo '<select multiple="multiple" name="name">';
                      while($row = mysql_fetch_assoc($query)
                      {
                      echo '<option value="'.$row['column_val'].'">'.$row['column_label'].'</option>';
                      }
                      echo '</select>';

                      The green is the query string
                      The blue is what the submitted data value should be
                      The red is the label that will appear in the combobox

                      I don't know how to integrate this into BV as I don't have it install to do any testing, but all you should have to change is removing the echo before and after the while loop (remove the select tag), and insert it into the html of a combobox in BV.

                      Register/Login Script
                      Do you use a Password Protected Directory? Need a way to allow users to make their own account, try my .htaccess Login Script

                      Comment

                      • navaldesign
                        General & Forum Moderator

                        • Oct 2005
                        • 12080

                        #12
                        Re: Calculations from MySQL

                        To populate a BV combobox, right click it and select HTML, then paste this in the Inside Tag:


                        ><?$query = mysql_query('query string');
                        while($row = mysql_fetch_assoc($query)
                        {
                        echo '<option value="'.$row['column_val'].'">'.$row['column_label'].'</option>';
                        }
                        ?

                        Note the starting > and the missing last >

                        I usually prefer (unless it is a VERY long array) to perform all queries in the Start of Page, and store the values retrieved from the database in a local array (in example, if the dropdown is for names, i store the values in an array called "$names) and then echo the values only:

                        ><?
                        for ($i=0 ; $i<count($names); $i++)
                        {
                        echo '<option value="'.stripslashes($name[$i]).'">'.stripslashes($name[$i]).'</option>
                        ';
                        }
                        ?

                        Please also note that if you want to make multiple choices, apart from checking the relevant checkbox (Watdaflip has added it using the word "multiple") you must also add square brackets [] after the checkbox name.

                        However, if you are using ABVFP to populate the database, it will receive the multiple values and combine them into a string like name1, name2, name3 etc.
                        Navaldesign
                        Logger Lite: Low Cost, Customizable, multifeatured Login script
                        Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
                        DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
                        Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

                        Comment

                        • Rob (SA)
                          Lieutenant Colonel

                          • Nov 2006
                          • 586

                          #13
                          Re: Calculations from MySQL

                          Hi George,

                          thanks for the info re - populating the combo box.

                          I have inderted as requested but am not succesful.

                          It proably has something to do with the changing of names in the documentation sent

                          Watdafip instruction re: colour confuese me a bit as I do not know whta he saying -maybe you scan shed some light on this
                          Kind Regards
                          Rob
                          www.gnjgf.co.za
                          www.oryan-projects.com

                          Comment

                          • navaldesign
                            General & Forum Moderator

                            • Oct 2005
                            • 12080

                            #14
                            Re: Calculations from MySQL

                            Did you first create the connection ? Did you actually create the query string ? My instructions (as well as those by Watdaflip) don't take care of that part as we can't know details and what exactly your query should be. So we only took it from that point forward.
                            Navaldesign
                            Logger Lite: Low Cost, Customizable, multifeatured Login script
                            Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
                            DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
                            Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

                            Comment

                            • Rob (SA)
                              Lieutenant Colonel

                              • Nov 2006
                              • 586

                              #15
                              Re: Calculations from MySQL

                              Hi George,

                              I have put the connection side in the html section ahead of you script.

                              If that makes sense?

                              $connect = mysql_connect("localhost", "******", "*********") or
                              die ("Hey loser, check your server connection.");
                              mysql_select_db("******a_Members");
                              $quey1="select * from _Form_Nr_3";
                              $result=mysql_query($quey1) or die(mysql_error());
                              ?>
                              ><?$query = mysql_query('query string');
                              while($row = mysql_fetch_assoc($query)
                              {
                              echo '<option value="'.$row['column_val'].'">'.$row['column_label'].'</option>';
                              }
                              ?
                              >
                              </select>
                              Kind Regards
                              Rob
                              www.gnjgf.co.za
                              www.oryan-projects.com

                              Comment

                              Working...
                              X