Use AJAX to filter mysql results with multiple checkbox option

Prashant Kumar

Prashant Kumar

I am a Software Developer with 6+ years of experience in software development. I have sharp skills in PHP language, Joomla, Magento, WordPress, HTML, CSS, Jquery, AJAX. Expert Magento Certified Developer (https://u.magento.com/certification/directory/dev/262179/). Love to take challenges in troubleshooting problem of software world. Familiar with web development and content management systems. I’m not a great programmer but I feel I’m a great implementer".

You may also like...

14 Responses

  1. Avatar Sabine says:

    Thanks for posting this example Prashant, but you have one error in your setup: in line 120 of index.php you call submit.php but you called the file ‘search.php’. That’s not going to work so either call the file submit.php or change line 120 to search.php.

  2. I have been browsing online more than 3 hours nowadays, but I by no means discovered any interesting article like yours. It is lovely value sufficient for me. Personally, if all site owners and bloggers made good content as you did, the internet will probably be much more useful than ever before.

  3. Avatar aniket says:

    thanks bro your script really worked for me

  4. Avatar Alen says:

    Hi Parshant, i am Alen and i am trying to develop e-diary for students. I have basic knowleg of the html, css, php, and ajax. I have finished login system with rols but i wont to make a registration system for each school which wil alone create prepared web page for registered school and which wil write comand in autenticate.php for the role for accessing the page. Did you can help me with this problem

    • Hi Alen, Yes of course I’ll help you. Can you please brief me what you want exactly so I’ll suggest you.

      • Avatar Alen says:

        I have created a login system with logging rules, if the admin redirects it to the admin side if another user sends it on a separate page.
        This is an example that I use:

        table.sql
        CREATE TABLE IF NOT EXISTS `reg_profesori` (
        `id` int(11) NOT NULL AUTO_INCREMENT,
        `username` varchar(20) NOT NULL,
        `password` varchar(20) NOT NULL,
        `role` varchar(20) NOT NULL,
        `Ime_i_prezime` varchar(50) DEFAULT NULL,
        `Email` varchar(50) DEFAULT NULL,
        `Broj_telefona` varchar(50) DEFAULT NULL,
        PRIMARY KEY (`id`)
        ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=9 ;

        Authenticate.php
        prepare($q);

        $query->execute(array(‘:username’ => $username, ‘:password’ => $password));

        // REDIREKCIJA AKO JE LOZINKA POGRESNA
        if($query->rowCount() == 0){
        header(‘Location: /..index.php?err=1’);
        }else{
        // PROVERA DALI LI SU PODACI TACNI
        $row = $query->fetch(PDO::FETCH_ASSOC);

        session_regenerate_id();
        $_SESSION[‘sess_user_id’] = $row[‘id’];
        $_SESSION[‘sess_username’] = $row[‘username’];
        $_SESSION[‘sess_userrole’] = $row[‘role’];

        echo $_SESSION[‘sess_userrole’];
        session_write_close();
        // REDIREKCIJA NA OSNOVU PRAVILA “ROLE”
        if( $_SESSION[‘sess_userrole’] == “admin”){
        header(‘Location: ../admin.php’);
        }else if ( $_SESSION[‘sess_userrole’] == “user”){
        header(‘Location: ../user.php’);
        }else if ( $_SESSION[‘sess_userrole’] == “user1”){
        header(‘Location: ../user1.php’);
        }else{
        header(‘Location: guest.php’);
        }
        // KRAJ SKRIPTE ZA REDIREKCIJU NA OSNOVU “PRAVILA”

        }

        ?>
        Now if I can create a form by which I will register users and rules, and automatically write the command to the authentičate.php. And automaticly create prepared page based on registration data.

  5. Avatar Raj says:

    how to persisit the state of checkbox on page reload. the checkbox state change on page reload please help.

  6. Avatar prachi says:

    hello sir you blog is very helpfull but can you try some in ysql queries not in pdo because i don’t get this point and i’m tottaly new in php plz help me

  7. Avatar prachi says:

    hello sir you blog is very helpfull but can you try some in mysql queries not in pdo because i don’t get this point and i’m tottaly new in php plz help me

  8. Avatar shiv says:

    i want to filter data with both checkboxes and searhbox. Is it possible ? if yes please give some hint. Thank you.

Leave a Reply to shiv Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.