Code Monkey home page Code Monkey logo

dtquick's Introduction

dtquick

dtquick is a lightweight and fast JavaScript library that simplifies the process of displaying data from databases. With minimal code, dtquick generates queries automatically and saves time. Check out the Live Demo to see it in action!

Usage

There are several ways to use dtquick:

  • Using CDN

Include the following script tag in the <head> section of your HTML document to use dtquick via CDN:

<script src="https://cdn.jsdelivr.net/gh/mohiwalla/dtquick@mohiwalla/index.js" defer></script>
  • Cloning the Repository

If you have Git installed on your machine, you can clone the repository using the following command:

git clone https://github.com/mohiwalla/dtquick.git
  • Installing via npm

If you have Node.js installed on your machine, you can use the following command to install the module:

npm install dtquick
  • Downloading the Script

You can also download the index.js file and include it in your HTML document using the following script tag:

<script src="path/to/index.js" defer></script>

Alternatively, you can copy the code from index.js and paste it into a <script> tag in your HTML document.

Initialization

To initialize dtquick, add a <div> element with id="dtquick".

Attributes

The following attributes must be added to the <div> element:

  • db-table

Specifies the name of the table to be used in the MySQL query to fetch data from the database.

  • cols

Specifies the names of the columns to be displayed in the table as a comma-separated list. Each column name should contain two parts: one for the client-side to display in the table's <th> and another for the server-side (which is the name used to create the column in the database). For example:

cols="S. no. = S, name = Name, E-mail = Email, Pass = Password"
  • file-name

Specifies the name of the server-side file to which dtquick will send an AJAX request for data.

Example

<div id="dtquick" db-table="dtquick" file-name="fetch.php" cols="User_name = name,......"></div>

<script src="https://cdn.jsdelivr.net/gh/mohiwalla/dtquick@mohiwalla/index.js" defer></script>

Server-Side File

The server-side file should fetch the query, the total number of rows available in the table, and the total found results as per the query. You can use any server-side language with it as per your comfort. Code samples for server-side scripts have been provided for reference in the following languages:

Note

Before using dtquick in production, please note that this library sends a query from the client-side to the server-side, which is not traditional. Therefore, anyone from the client-side can modify the query to fetch data from your table, which is a potential risk to your data. If you want to prioritize safety, consider using DataTables as it creates queries at the server end and reduces the risk. The purpose of creating queries at the client-end was to keep the structure of both client and server-side files simple and easy to use for newbies. If you find any bugs in the code or any possible improvements without compromising the simplicity of usage, you can send a pull request or modified code to [email protected]. The existing code will be replaced by the code provided by you as soon as the examination is finished, and your name will be in the list of Contributors as well. So, don't hesitate to give it a try. Lastly, if you appreciate the effort, consider giving a star to this repository.

Inspired by

DataTables

License

dtquick is distributed under the MIT License.

Made with ❤️ by mohiwalla

dtquick's People

Contributors

codewithsonyy avatar mohiwalla avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

dtquick's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.