AJAX: PHP with SQLite database

For discussions about programming, and for programming questions and advice


Moderator: Forum moderators

Post Reply
User avatar
puppy_apprentice
Posts: 661
Joined: Tue Oct 06, 2020 8:43 pm
Location: land of bigos and schabowy ;)
Has thanked: 4 times
Been thanked: 107 times

AJAX: PHP with SQLite database

Post by puppy_apprentice »

Sorting and filtering is made using SQL queries.

Source example for MySQL:
https://www.w3schools.com/php/php_ajax_database.asp
SQL queries:
https://www.w3schools.com/sql/sql_syntax.asp

Attachments
ajax_php_sqlite.zip
(18.19 KiB) Downloaded 24 times
User avatar
puppy_apprentice
Posts: 661
Joined: Tue Oct 06, 2020 8:43 pm
Location: land of bigos and schabowy ;)
Has thanked: 4 times
Been thanked: 107 times

Re: AJAX: PHP with SQLite database

Post by puppy_apprentice »

index.html with with ascending and descending sorting.

Attachments
index.zip
(1.08 KiB) Downloaded 21 times
User avatar
rockedge
Site Admin
Posts: 5746
Joined: Mon Dec 02, 2019 1:38 am
Location: Connecticut,U.S.A.
Has thanked: 2023 times
Been thanked: 2110 times
Contact:

Re: AJAX: PHP with SQLite database

Post by rockedge »

@puppy_apprentice This version works well and looks good. Seems to check all the boxes but I would like to find a way to prevent the table headers from being highlighted on a mouse cursor hover event.

Works well on Apache server from XAMPP but not from the Hiawatha local server

User avatar
puppy_apprentice
Posts: 661
Joined: Tue Oct 06, 2020 8:43 pm
Location: land of bigos and schabowy ;)
Has thanked: 4 times
Been thanked: 107 times

Re: AJAX: PHP with SQLite database

Post by puppy_apprentice »

rockedge wrote: Thu Sep 28, 2023 8:33 pm

I would like to find a way to prevent the table headers from being highlighted on a mouse cursor hover event.

Delete lines with :hover from <style> part of html file.

rockedge wrote: Thu Sep 28, 2023 8:33 pm

Works well on Apache server from XAMPP but not from the Hiawatha local server

I was check it only on mongoose server.
https://code.google.com/archive/p/mongoose/

Maybe php for Hiawatha is not configurated. If it render other php files try this, delete from php file those lines:

Code: Select all

if (isset($_SERVER['HTTP_REFERER'])){
}else{
	header('Location: index.html');
}

Or maybe in html file add full address to index.php:

Code: Select all

xmlhttp.open("GET","index.php?id="
xmlhttp.open("GET","http://localhost/index.php?id="

and start from html file not php.

Edit:
Cannot run ajax on Hiawatha

User avatar
rockedge
Site Admin
Posts: 5746
Joined: Mon Dec 02, 2019 1:38 am
Location: Connecticut,U.S.A.
Has thanked: 2023 times
Been thanked: 2110 times
Contact:

Re: AJAX: PHP with SQLite database

Post by rockedge »

This Hiawatha server is outfitted with quite a few bells and whistles and runs both mysql (mariaDB) and sqlite3. All the major and some specialized PHP modules are up and running.

I found out the problem was the hard drive the server is using is FULL. No more room to write files. That includes the sockets the mysql and sqlite3 databases need and all of the caches and temp files that can not be created and written too. Turns out after I cleared out 175 G of stuff off of the HDD, the Hiawatha/MySQL/PHP/PERL (HMPP stack) server is again, running everything as expected.

Took some digging in the logs to find any mention of a disk out of space error

User avatar
puppy_apprentice
Posts: 661
Joined: Tue Oct 06, 2020 8:43 pm
Location: land of bigos and schabowy ;)
Has thanked: 4 times
Been thanked: 107 times

Re: AJAX: PHP with SQLite database

Post by puppy_apprentice »

Ok. Good to know.

User avatar
smokey01
Posts: 163
Joined: Sun Jul 12, 2020 10:46 am
Location: Australia
Has thanked: 21 times
Been thanked: 23 times
Contact:

Re: AJAX: PHP with SQLite database

Post by smokey01 »

Somethings are not as obvious as they should be.

I remember when I was setting up phpliteadmin.php, I couldn't get the edit and delete links to show up. It turned out to be a folder permission issue. The folder needed to be writable as phpliteadmin.php writes temp files to the directory.

User avatar
smokey01
Posts: 163
Joined: Sun Jul 12, 2020 10:46 am
Location: Australia
Has thanked: 21 times
Been thanked: 23 times
Contact:

Re: AJAX: PHP with SQLite database

Post by smokey01 »

Looks nice here running on my hiawatha server.
Is it suppose to show data?

Attachments
xscreenshot-20231002T172700.png
xscreenshot-20231002T172700.png (8.44 KiB) Viewed 760 times
User avatar
puppy_apprentice
Posts: 661
Joined: Tue Oct 06, 2020 8:43 pm
Location: land of bigos and schabowy ;)
Has thanked: 4 times
Been thanked: 107 times

Re: AJAX: PHP with SQLite database

Post by puppy_apprentice »

Yep but on Hiawatha could be problems.
I'm using only busybox httpd or mongoose (or else small servers) to test pages.

User avatar
smokey01
Posts: 163
Joined: Sun Jul 12, 2020 10:46 am
Location: Australia
Has thanked: 21 times
Been thanked: 23 times
Contact:

Re: AJAX: PHP with SQLite database

Post by smokey01 »

Does this require other code to read from the sqlite database or is this code stand alone?
Maybe if you zip up all your files I will understand it better. Then I will know if it's a hiawatha problem or not.

puppy_apprentice wrote: Mon Oct 02, 2023 7:20 am

Yep but on Hiawatha could be problems.
I'm using only busybox httpd or mongoose (or else small servers) to test pages.

User avatar
puppy_apprentice
Posts: 661
Joined: Tue Oct 06, 2020 8:43 pm
Location: land of bigos and schabowy ;)
Has thanked: 4 times
Been thanked: 107 times

Re: AJAX: PHP with SQLite database

Post by puppy_apprentice »

This is stand-alone. No extra scripts. Only php file as a backend and html file as frontend. I never used Hiawatha as other servers meet all my needs.

User avatar
smokey01
Posts: 163
Joined: Sun Jul 12, 2020 10:46 am
Location: Australia
Has thanked: 21 times
Been thanked: 23 times
Contact:

Re: AJAX: PHP with SQLite database

Post by smokey01 »

So the index.html is the front end, where is the php backend. I've tried renaming the contact17.php to index.php that didn't work. I also striped out all off html code and just left the php code, that didn't work either. How is it getting the info from contact8.sqlite?
What am I missing?

puppy_apprentice wrote: Mon Oct 02, 2023 7:44 am

This is stand-alone. No extra scripts. Only php file as a backend and html file as frontend. I never used Hiawatha as other servers meet all my needs.

User avatar
puppy_apprentice
Posts: 661
Joined: Tue Oct 06, 2020 8:43 pm
Location: land of bigos and schabowy ;)
Has thanked: 4 times
Been thanked: 107 times

Re: AJAX: PHP with SQLite database

Post by puppy_apprentice »

In the first post are both files. In the second post is the updated (new version) html file. Replace the older version of the html file with the newer one.

User avatar
rockedge
Site Admin
Posts: 5746
Joined: Mon Dec 02, 2019 1:38 am
Location: Connecticut,U.S.A.
Has thanked: 2023 times
Been thanked: 2110 times
Contact:

Re: AJAX: PHP with SQLite database

Post by rockedge »

All of the files and directories the web server uses, must be owned by the web server user.

The AJAX version runs on the XAMPP instance I also have and on my main Apache2 server that is installed side-by-side with Hiawatha. I will look into why it displays differently but most likely it is that the PHP is missing a library.

User avatar
smokey01
Posts: 163
Joined: Sun Jul 12, 2020 10:46 am
Location: Australia
Has thanked: 21 times
Been thanked: 23 times
Contact:

Re: AJAX: PHP with SQLite database

Post by smokey01 »

I completely missed that first post.
Thanks for that.

puppy_apprentice wrote: Mon Oct 02, 2023 2:48 pm

In the first post are both files. In the second post is the updated (new version) html file. Replace the older version of the html file with the newer one.

Post Reply

Return to “Programming”