I have an sqlite database and date is one of the columns in it. In my webpage, the user needs to be able to select a range of dates, retrieve the rows that are inside that date range, and display that information in the webpage. I've already set up the date inputs, but other than that, I don't know how to go about filtering the database using the date range and then displaying the hits.
Asked
Active
Viewed 163 times
0
-
Can you show your current code? What does your table(s) look like? – dmikester1 Sep 28 '18 at 16:00
-
Thank you. Can you also show your current code? What have you tried? – dmikester1 Sep 28 '18 at 16:16
-
@dmikester1 My code right now is just the HTML for the dates inputs and a button to enter the values. I edited to show the database and what the html looks like. – Miguel Ángel Gárate Fox Sep 28 '18 at 16:20
-
OK, are you using a server side language to connect to the database? I'm not super familiar with sqlite3, but assuming it is similar to mysql. – dmikester1 Sep 28 '18 at 16:22
-
I know what query to use to get the information out of the database, however, I don't know how to query the db from the browser. – Miguel Ángel Gárate Fox Sep 28 '18 at 16:23
-
But what languages are you using? Are you using just html and javascript? Or are you using a server side language like PHP as well? – dmikester1 Sep 28 '18 at 16:25
-
Right now I'm just using HTML and JS, correct. Have never used PHP, so I don't know if that would be the best option to get this done, or if there's something more suited for it. – Miguel Ángel Gárate Fox Sep 28 '18 at 16:29
-
Where is this being done? On a hosted server? On your personal PC? Or is it on the RPi hence your tag? – dmikester1 Sep 28 '18 at 17:11
-
It's an apache server on the RPi. – Miguel Ángel Gárate Fox Sep 28 '18 at 17:15
-
While it looks like you can access [sqlite3 in javascript](https://stackoverflow.com/questions/13192643/is-it-possible-to-access-an-sqlite-database-from-javascript), it looks difficult and a lot of work. I would highly recommend installing PHP on your RPi and using that to access your sqllite3 DB. There are tons of great tutorials out there, here is [one](https://howtoraspberrypi.com/how-to-install-web-server-raspberry-pi-lamp/). – dmikester1 Sep 28 '18 at 17:21
-
Thank you for setting me on my way, I really appreciate it! – Miguel Ángel Gárate Fox Sep 28 '18 at 17:25
-
No problem, and connecting to sqlite3 with PHP is [super easy](https://stackoverflow.com/questions/5041737/how-to-connect-to-a-sqlite3-db-with-php) – dmikester1 Sep 28 '18 at 17:29