Announcement

Collapse
No announcement yet.

Fill in a GOMenu with dinamic variables

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Fill in a GOMenu with dinamic variables

    Hello dear colleagues from the VH forum,

    Can someone explain how to load PHP variables on a Bluevoda GO menu (without the GO button).

    I already know how to fill in a combobox with the variables and when I was going to try the same approach I realized that couldn't be done.

    I want to use it on a page that is listing on my tests some several thousand contacts and I want to create a list of page numbers (similar to phpmyadmin...) on this GO menu that allow me to choose a page number and GO to it.

    I already have a GO menu (alphabetic from A...Z) that will list me all contacts started by A, and B, etc,etc and is working fine, because I go to the SELECT sentence and tell the mySQL database to look for the records WHERE name_contac = '$variableA'.
    $variableA = 'A%' that I pick up from the GO menu when I choose the 'A 'option.

    For the jump to PAGE number x, I can't do this manually as in the A,B,C... example, because I don't know how many records will the database retrieve (so I don't know how many page numbers, only on runtime, after dividing the total number of records by 13 which is my "show" of records per page.

    Also the number of records will be different from one user to another, has to be done during runtime.

    Thanks in advance for all the answers,
    pipesportugal

  • #2
    Re: Fill in a GOMenu with dinamic variables

    I may be misunderstanding what you are wanting to do, but if you are trying to get a the number of pages for each letter before the user actually selects the letter why don't you just do a query for it when you get the initial list. Just create an array A-Z, and loop through it doing a query saving the number of pages for each letter to another array. (or the same and make it multi-dim, doesn't matter).

    If this isn't what you are asking sorry, maybe explain a different way.

    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


    • #3
      Re: Fill in a GOMenu with dinamic variables

      Hi Watdaflip,

      It's easy to create a dynamic GO menu when You know how many "options" You want there as You can see here:



      But.... as You can see below at phpmyadmin, I can only know the number of pages (automatically the number of links I have to create...) after making the query.



      This is what I want to do... I only know the number of "options/links" to create during runtime.

      Can You help ?

      pipesportugal

      Comment


      • #4
        Re: Fill in a GOMenu with dinamic variables

        You can't doit easily using the BV Go menu, because, if you paste the necessary code in the Inside body tag, it will go BEFORE the <select> statement.

        You can, however, do this:


        Suppose that you have already completed your database query and you have stored the values (text) and URLs for the links that go in the GoMenu, in two arrays: $value and $URL. For this example, just to avoid quering the database, you need to define the two arrays. Let's do so by placing the below code in your Start of Page of your BV page:

        <?
        $value = array(1,2,3);
        $URL[0] = "http://www.dbtechnosystems.com";
        $URL[1] = "http://www.dbtechnosystems.com/contact.php";
        $URL[2] = "http://www.dbtechnosystems.com/free_abvfp.php";
        ?>


        Now place a html box in your page. Paste in the box, the following code:

        <form name="GoMenuForm1" action="">
        <select name="GoMenu" onchange="OnGoMenuFormLink(this)" style="width:296px">
        <option >Please select a Link</option>
        <?
        for ($i = 0; $i < count($value); $i++) {

        $option = "<option ";
        $option .= "class=\"_self\" value=\"$URL[$i]\">$value[$i]</OPTION>";
        echo "$option<br>";
        }
        ?>
        </select>
        </form>

        As you can see, the loop will automatically take care of the number of options, once you have finished quering the database and populated the arrays.

        Further more, BV automatically creates a Javascript function when a Go menu is used. Since this is not a BV Go menu, this function is missing. So you need to copy it from here and place it in the Between Head Tag of your BV page:

        <script language="JavaScript" type="text/javascript">
        <!--
        function OnGoMenuFormLink(GoList)
        {
        var url = GoList.options[GoList.selectedIndex].value;
        var target = GoList.options[GoList.selectedIndex].className;
        GoList.selectedIndex=0;
        GoList.blur();
        if (url)
        {
        NewWin=window.open(url,target);
        window['NewWin'].focus()
        }
        }
        //-->
        </script>
        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


        • #5
          Re: Fill in a GOMenu with dinamic variables

          Hi navaldesign, Thank You,

          Sorry for coming back so late about this subject, and I would like to conclude it and leave here my suggestions for helping others:

          1) As I had other(static) GOMenu's at this webpage I already had the java function inside the page, so I didn't need to place it at the page anymore.

          2) My intention was to display in the GOmenu something like:

          Page 1
          Page 2
          ....
          Page n

          I used a constant that I can easily change at anytime called $lines_per_page = 15;

          The number of pages I was geting it during runtime using the following process:
          $number_of_pages = $result_of_the_mysqlcount / $lines_per_page;

          Then I had a first script called "load_array_of_urls", where I was puting in the array $url_page[] the pages(url's).

          In these url's I used the GET method the pass the variables $lines_per_page and "$first_line" to a PROGRAM.php

          for ($i = 1; $i <= $number_of_pages; $i++)
          {
          $first_line= ($i * $lines_per_page) -($lines_per_page - 1);
          $url_page[$i] = PROGRAM.php?lines_per_page=$lines_per_page&first_l ine=$first_line;
          }

          This 2 variables You need them for the SELECT sentence of mySQL query.

          In the PROGRAM.php You have a mySQL select sentence that should be something like this:

          SELECT * FROM file WHERE .... ORDER BY .....LIMIT $first_line, $lines_per_page

          This automatically shows You on screen a "$lines_per_page" number of lines, starting on the $first_line.
          -------------------------------------------

          About the array $value You adviced me to use to load the Gomenu, array(1,2,3...), I did not use it.
          I used the numbers itself starting from 1 to $number_of_pages as I show below:
          Here's how I loaded the GOmenu:

          for ($i = 1; $i <= $number_of_pages; $i++)
          {
          $option = "<option ";
          $option .= "class=\"_mostra\" value=\"$url_page[$i]\">Page:$i</option>";
          echo "$option\n";
          }

          I don't know if it's confusing, and if someone needs further help on this one, please leave feedback here as I am checking this subforum on a regular basis and I am glad to help.

          Thanks again navaldesign,

          pipesportugal

          Comment


          • #6
            Re: Fill in a GOMenu with dinamic variables

            I am not sure that i have understood well your initial question and what you are now saying.
            I thought that your issue was how to dynamically populate a BV Gomenu.
            I didn't even got into the process of HOW you query the database, or what you need to place in there.

            Only one small remark:
            $number_of_pages = $result_of_the_mysqlcount / $lines_per_page;
            is not correct, as there might be a last page with less that $lines_per_page listings

            One more thing:

            This way, you are sending the info from a page to another (from a script to another).
            Why, instead of using a Go Menu, don't you use a form dropdown? The only difference is one more click (you need to place a submit button) for the user, but is a LOT more easy to use and configurate as you can separate the populating code from the visual setup. In fact, in that case, the dropdown can be a BV one (as we had talked about in that other thread) so you can manipulate font type / size / colour / background very easily using BV's tools.
            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


            • #7
              Re: Fill in a GOMenu with dinamic variables

              Hello good morning,

              In fact You are right, the 2 GOmenu's look a little odd in the middle of other info text boxes I have there. They are a little bit out of the context.

              With the dropdown menu I could change the colour/font, etc.
              I was just following the phpmydmin idea, which is, the user chooses the page number and jumps imediately to the requested page.

              There wouldn't be any problem if there was a "show" button at the side of the dropdown menu. I will take that in consideration next time.

              Regarding the $number_of_pages I used the intval() function + 1 to calculate the number of pages and is working ok. Except if the quocient was already a perfect integer itself, which in this case did nothing.

              For mySQL to make a valid query the important variable to use at the LIMIT is the "$first_line" and the "$number_of_lines_per_page" and those 2 are being correctly passed in the url, at least, I checked till page 37 (per 16)= 592 records.

              Really in my tests there were 595 records.
              If the last page contains only 3 lines, mySQL doesn't care the select sentence will select 16($number_of_lines_per_page) records starting in 593($first_line) (till 609), so it just shows those 3.

              Thank You for Your advice,
              pipesportugal

              Comment

              Working...
              X