+2 votes
4 views

I am trying to implement autocomplete on the attribute named “search”, i imported all ajax classes and tried to put the JS code in it, but its not really working.

Search.php is used to fetch all the values, and all will be put on header.php page…

header.php page code

<?php ob_start(); ?> <?php include "../db.php"?> <?php include "../function.php"?> <?php session_start(); ?>

<!DOCTYPE HTML>

Symphony.com addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); } <!-- Bootstrap<?php ob_start(); ?> <?php include "../db.php"?> <?php include "../function.php"?> <?php session_start(); ?>

<!DOCTYPE HTML>

Symphony.com addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); } <!-- Bootstrap rel="stylesheet"> <!-- jQuery --> <!-- lined-icons --> <!-- //lined-icons -->
https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js
https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js

    $(function() {
         $("#search").autocomplete({
            source: "search.php",
            minLength: 2,
            select: function (event, ui) {
                event.preventDefault();
                $('#search').val(ui.item.id);
            }
        });
    });

<!-- Meters graphs -->
http://js/jquery-2.1.4.js
<!-- /w3layouts-agile -->
<!-- left side start-->

Symphony

        S 



    <!--logo and iconic logo end-->

Home

Profile

            Upload";
                    echo "

Add Artist "; echo " Add Albums "; } ?>

Artists

Albums

Events

About Us

My Favourities

Contact

            Log Out";
                    } else {
                        echo "

Log In "; } } else{ echo " Log In "; }

            ?>






</div>
<!-- /w3layouts-agile -->
<!-- app-->

<!-- //app-->
<!-- /w3l-agile -->
<!-- signup -->

<!-- //signup -->
<!-- /w3l-agile -->
<!-- left side end-->
<!-- main content start-->
























                </div>
                <!-- search-scripts -->
                http://js/classie.js
                http://js/uisearch.js

                    new UISearch( document.getElementById( 'sb-search' ) );

                <!-- //search-scripts -->
                <!---->



                    http://js/mediaelement-and-player.min.js







                        " class="btn btn-success" style="height: 50px; width: 120px; visibility: visible; background-color: black">


                    </form>
                </div>




            </div>
            <!-------->
        </div>


    </div>
    <!--notification menu end -->
    <!-- //header-ends -->
    <!-- /w3l-agileits -->

search.php page

<?php include "../db.php"?> <?php $searchTerm = $_GET['term']; $query = $connection->query("select * from music where title like '%".$searchTerm."%' order by id asc");

$skillData = array(); if($query->num_rows > 0){ while($row = $query->fetch_assoc()){ $data['id'] = $row['id']; $data['value'] = $row['title']; array_push($skillData, $data); } }

echo json_encode($skillData); ?>

by (1.7k points)   | 4 views

Please log in or register to answer this question.

Related questions

0 votes
0 answers
+2 votes
0 answers
+3 votes
0 answers
asked Jun 17 by noor (1.1k points) | 3 views
+2 votes
0 answers
asked Jun 17 by abrishnoor (1.7k points) | 15 views
+1 vote
0 answers
+2 votes
0 answers
+2 votes
0 answers




Welcome to Meansflow - Where Developers and Students Learn, Share, & Build Careers, where you can ask questions and receive answers from other members of the community.
106 questions
75 answers
36 comments
93 users