Autocomplete city from database The Next CEO of Stack OverflowFiltering error when using custom Varien object collection in admin gridMagento Database Tables restoreHow to add Form Fields to a custom Report?Dropdown city in checkoutCreate invoice and shipment in magento via cron based on store view and order ageGetting data from Magento database into order/invoice emails and PDFGet All Orders from DatabaseExtract data from database and display it in a formLet customers add their desired name in each productPicking items from the magento database

Should I tutor a student who I know has cheated on their homework?

How does the Z80 determine which peripheral sent an interrupt?

How did people program for Consoles with multiple CPUs?

How to prevent changing the value of variable?

What's the best way to handle refactoring a big file?

Why has the US not been more assertive in confronting Russia in recent years?

WOW air has ceased operation, can I get my tickets refunded?

What happened in Rome, when the western empire "fell"?

Is there a way to save my career from absolute disaster?

MessageLevel in QGIS3

Why am I allowed to create multiple unique pointers from a single object?

Return the Closest Prime Number

How to invert MapIndexed on a ragged structure? How to construct a tree from rules?

"In the right combination" vs "with the right combination"?

Unreliable Magic - Is it worth it?

Multiple labels for a single equation

Do I need to enable Dev Hub in my PROD Org?

Can you replace a racial trait cantrip when leveling up?

How do we know the LHC results are robust?

What happens if you roll doubles 3 times then land on "Go to jail?"

What exact does MIB represent in SNMP? How is it different from OID?

In excess I'm lethal

sp_blitzCache results Memory grants

Is it my responsibility to learn a new technology in my own time my employer wants to implement?



Autocomplete city from database



The Next CEO of Stack OverflowFiltering error when using custom Varien object collection in admin gridMagento Database Tables restoreHow to add Form Fields to a custom Report?Dropdown city in checkoutCreate invoice and shipment in magento via cron based on store view and order ageGetting data from Magento database into order/invoice emails and PDFGet All Orders from DatabaseExtract data from database and display it in a formLet customers add their desired name in each productPicking items from the magento database










1















I want to create an autocomplete input for city in onepagecheckout, and registration form.



I've a database table with all my data and I've a function php tha give me the json that look like this



["comune":"Santa Brigida","provincia":"Bergamo","cap":"24014", ...,...]


In my php code I create a filter like this



 $comuniItaliani= Mage::getModel('comuniItaliani/comuniItaliani')->getCollection()->addFieldToFilter('comune', array('like' => $comuneCode.' %'));


But in this way the filter works only if a word is complete, i want to filter when the word start form:



ex. If I refer to the piece of json written obove:



> If I filter for "Santa" it work perfectly and gives me "Santa Brigida" 
but I want it to work even with "san" or "sant"









share|improve this question




























    1















    I want to create an autocomplete input for city in onepagecheckout, and registration form.



    I've a database table with all my data and I've a function php tha give me the json that look like this



    ["comune":"Santa Brigida","provincia":"Bergamo","cap":"24014", ...,...]


    In my php code I create a filter like this



     $comuniItaliani= Mage::getModel('comuniItaliani/comuniItaliani')->getCollection()->addFieldToFilter('comune', array('like' => $comuneCode.' %'));


    But in this way the filter works only if a word is complete, i want to filter when the word start form:



    ex. If I refer to the piece of json written obove:



    > If I filter for "Santa" it work perfectly and gives me "Santa Brigida" 
    but I want it to work even with "san" or "sant"









    share|improve this question


























      1












      1








      1


      1






      I want to create an autocomplete input for city in onepagecheckout, and registration form.



      I've a database table with all my data and I've a function php tha give me the json that look like this



      ["comune":"Santa Brigida","provincia":"Bergamo","cap":"24014", ...,...]


      In my php code I create a filter like this



       $comuniItaliani= Mage::getModel('comuniItaliani/comuniItaliani')->getCollection()->addFieldToFilter('comune', array('like' => $comuneCode.' %'));


      But in this way the filter works only if a word is complete, i want to filter when the word start form:



      ex. If I refer to the piece of json written obove:



      > If I filter for "Santa" it work perfectly and gives me "Santa Brigida" 
      but I want it to work even with "san" or "sant"









      share|improve this question
















      I want to create an autocomplete input for city in onepagecheckout, and registration form.



      I've a database table with all my data and I've a function php tha give me the json that look like this



      ["comune":"Santa Brigida","provincia":"Bergamo","cap":"24014", ...,...]


      In my php code I create a filter like this



       $comuniItaliani= Mage::getModel('comuniItaliani/comuniItaliani')->getCollection()->addFieldToFilter('comune', array('like' => $comuneCode.' %'));


      But in this way the filter works only if a word is complete, i want to filter when the word start form:



      ex. If I refer to the piece of json written obove:



      > If I filter for "Santa" it work perfectly and gives me "Santa Brigida" 
      but I want it to work even with "san" or "sant"






      magento-1.9 magento-1.7 magento-1.8 collection onepage-checkout






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 14 mins ago









      Teja Bhagavan Kollepara

      3,01241949




      3,01241949










      asked Oct 7 '14 at 7:52









      MarcoMarco

      458




      458




















          1 Answer
          1






          active

          oldest

          votes


















          2














          You have a space char before the % in array('like' => $comuneCode.' %').

          So when you type in san the query will look like this:



          Where ... AND comune LIKE 'san %'.


          That's why it does not find anything, but it works when you type in Santa
          Santa Brigada is matched by LIKE 'santa %'.

          Just remove that space.



          array('like' => $comuneCode.'%')





          share|improve this answer























            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "479"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f38185%2fautocomplete-city-from-database%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            2














            You have a space char before the % in array('like' => $comuneCode.' %').

            So when you type in san the query will look like this:



            Where ... AND comune LIKE 'san %'.


            That's why it does not find anything, but it works when you type in Santa
            Santa Brigada is matched by LIKE 'santa %'.

            Just remove that space.



            array('like' => $comuneCode.'%')





            share|improve this answer



























              2














              You have a space char before the % in array('like' => $comuneCode.' %').

              So when you type in san the query will look like this:



              Where ... AND comune LIKE 'san %'.


              That's why it does not find anything, but it works when you type in Santa
              Santa Brigada is matched by LIKE 'santa %'.

              Just remove that space.



              array('like' => $comuneCode.'%')





              share|improve this answer

























                2












                2








                2







                You have a space char before the % in array('like' => $comuneCode.' %').

                So when you type in san the query will look like this:



                Where ... AND comune LIKE 'san %'.


                That's why it does not find anything, but it works when you type in Santa
                Santa Brigada is matched by LIKE 'santa %'.

                Just remove that space.



                array('like' => $comuneCode.'%')





                share|improve this answer













                You have a space char before the % in array('like' => $comuneCode.' %').

                So when you type in san the query will look like this:



                Where ... AND comune LIKE 'san %'.


                That's why it does not find anything, but it works when you type in Santa
                Santa Brigada is matched by LIKE 'santa %'.

                Just remove that space.



                array('like' => $comuneCode.'%')






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Oct 7 '14 at 8:09









                MariusMarius

                167k28319686




                167k28319686



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Magento Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f38185%2fautocomplete-city-from-database%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Nidaros erkebispedøme

                    Birsay

                    Was Woodrow Wilson really a Liberal?Was World War I a war of liberals against authoritarians?Founding Fathers...