Working on a project (one of my first!!!) and hit a little bump. I think there may be multiple ways to do what I am trying to do and wanted to hear some suggestions.
I am working on a UI that will display data from a database (sqlite). It will be displayed in a table that will have search fields to narrow down the data.
I am using Node. I can successfully console.log the data from the db file. I can also send it directly to the browser (without displaying my html page).
What I would like to do is take the data, send it to my html file where I have the table and then display it. (I think I should first ask, does this approach make sense or should I be going about this a different way?)
I don’t know how to take data from the js file (that was pulled from the db) and send it to the html file. How do I do this? How hard is it to do with straight js code? Should I use a middle wear? Should I do js first, get it working, then use a middle wear to help for a better learning experience?
Thanks for your help group!
Here’s an example. Learn the principle then apply it to your stack.
My search was “create a datatable in html from an sql database” the keyword being datatable and sometimes you have to block microsoft stuff with the minus operator like
-c# -microsoft -office
Thanks for the suggestion. My antivirus reports your link as a potential threat. Not sure what’s going on there.
Can you expand on “learn the principal”? Most of the search results point to creating data tables. I am not creating a db, just reading from one.
Must be because I’m still new but all these different … (modules???) make it very confusing (express, ejs, react, ajax, jade/pug, use php). I find a lot of responses to questions similar to mine say to use one of these instead of whatever someone is using but then there isn’t an explanation why.
Maybe your AV considers links that don’t expose the link in the text a virus. https://itsolutionstuff.com/post/php-jquery-datatables-with-mysql-database-example-from-scratchexample.html
Your post says that you are reading data from a database. Databases have tables. This is not the use of datatable here. Here datatable is programmatically creating a table (here in html) from a datasource (here local database) could also be a feed, json, csv, or database connection online. You don’t necessarily no the number of columns and row or the update frequency so you use a programming language to handle those variables. When you display data in excel from an online datasource it calls it a datatable.
The link still brings up the alert. Just an FYI.
Please excuse my trouble understanding as I am still learning but I am not understanding your explanation. Maybe I did not provide enough info in my question.
I am using NodeJS and express. I am trying not to use PHP at this time. I am able to read the database (or the table from the database) and console log it. Where I am stuck is when I pull the data into a JS variable how do I send that to my html file to display it in a table?
I’ll guess you got JSON back. Here’s how to make a table from JSON.