M
M
miksha2018-02-18 00:03:46
PHP
miksha, 2018-02-18 00:03:46

How to combine vue.js and PHP with MYSQL?

Sorry for the stupid question - newbie...
Does anyone have a working example?
There is a database - it has a table with columns - id and name, for example.
There is a db.php file where we connect to the database, perform some actions with it, etc.
There is an index.html file where vue.js is linked.
How to simply display a list of table rows via vue.js??
The vue.js documentation had this example:

// bootstrap the demo
var demo = new Vue({
  el: '#demo',
  data: {
    searchQuery: '',
    gridColumns: ['name', 'power'],
    gridData: [
      { name: 'Chuck Norris', id: 123 },
      { name: 'Bruce Lee', id: 321 },
      { name: 'Jackie Chan', id: 1235 },
      { name: 'Jet Li', id: 423535 }
    ]
  }
})

Here's how to transfer data from our database to gridData ?
How to start a cycle that fills all this stuff?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Decadal, 2018-02-18
@Decadal

You still have a lot to learn, you can’t tell everything in one answer.
Vue is a front-end, interface interactivity thing, so there is almost nothing in its documentation about working with the server. But there is work with the server itself, it is built on the basis of requests to the server. AJAX is relevant for you (this is also a front-end, but not part of vue).
AJAX allows you to request something from the server without reloading the page. Now we're getting to PHP - the request needs to be handled by a server-side language, and you'd be better off using a framework rather than pure PHP.
In general terms, the server parses the query parameters and builds a query to the database (SQL-> DML) based on them. This is where mysql starts.
The response to the sql query contains a slice of the data requested by the user. The response is converted first into arrays or objects of the server language of your choice, and then into JSON (or xml, or another data format), after which it is passed to the AJAX request handler.
To give you a working example, I'll send you the whole project. Get acquainted with the technologies I mentioned separately, you will have to spend a couple of evenings on this)

I
Infokain, 2020-06-17
@Infokain

I am also new to this business, but I can strongly recommend a ready-made project in a vue.js box for the front-end and Laravel7 for the back-end, https://coreui.io/vue-laravel/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question