How to create a MySQL database connection in javascript of Knockout.js file?

I have created the following table in MYSQL and a file in Knockout.js.I want that the data we are entering in the Knockout.js through variable pf should be stored in the table “PORTFOLIO”.The database connection I want to implement is through javascript only.I tried creating a database connection between MYSQL and Knockout.js but was not successful.Kindly help.

  pf VARCHAR (255)

File in Knockout.js

<form data-bind="submit: addpf">
Add Portfolio: <input data-bind="value: newpf" placeholder="Who needs to be added?" />
    <button type="submit">Add</button>

<ul data-bind="foreach: pf, visible: pf().length > 0">
        <input type="checkbox" data-bind="checked: isDone" />
        <input data-bind="value: title, disable: isDone" />
        <a href="#" data-bind="click: $parent.removepf">Delete</a>

You have <b data-bind="text: oldpf().length">&nbsp;</b> New Portfolios
<span data-bind="visible:  oldpf().length == 0"></span>


function pf(data) {
        this.title = ko.observable(data.title);
        this.isDone = ko.observable(data.isDone);

    function pfListViewModel() {
        // Data
        var self = this; = ko.observableArray([]);
        self.newpf = ko.observable();
        self.oldpf = ko.computed(function() {
            return ko.utils.arrayFilter(, function(pf) { return !pf.isDone() });

        // Operations
        self.addpf = function() {
   pf({ title: this.newpf() }));

        self.removepf = function(pf) { };

    ko.applyBindings(new pfListViewModel());

Source: mysql

Leave a Reply

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