How do I link a database to my html code? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

How do I link a database to my html code?

My code involves a small form and a submit button. The submit button must update a connected html database code where every response is recorded. I am able to alert the respondent about the response being recorded but not able to record response in the database html document.

27th Nov 2023, 12:54 PM
Aditi
Aditi - avatar
6 Answers
+ 7
A database must be created first and access to the database is programmed using classic backend scripting languages such as PHP etc. As the data is now available as variables, a JavaScript code is generated using these variables, which makes the database structure comprehensible using multidimensional JavaScript arrays. If such a multidimensional array with the database data is available, the data from this array can be retrieved and used through loops. https://sololearn.com/discuss/3244525/?ref=app https://sololearn.com/discuss/3226494/?ref=app https://sololearn.com/discuss/3100945/?ref=app
27th Nov 2023, 2:45 PM
JaScript
JaScript - avatar
+ 6
A backend programming language (PHP or Python or Node.js etc.) is essentially required and all these parts inclusive HTML, CSS, Javascript codes and database have to be on a server, which should be all time online. In this way you can test that on your PC: https://www.geeksforgeeks.org/how-to-insert-form-data-into-database-using-php/
27th Nov 2023, 3:51 PM
JaScript
JaScript - avatar
+ 2
Is PHP essentially required to link them or can I just use HTML to link them and continue with the code ? Also, an HTML document can be used as the database for recording the data, right ? It can be updated as and when the form is filled.
27th Nov 2023, 3:35 PM
Aditi
Aditi - avatar
+ 2
You need to use a language that provided a server, best ones are node.js or php, I personally recommend node.
29th Nov 2023, 7:39 AM
Ahmad Muhammad
+ 1
Y-Kh first let's not blame python for a c++ code and look at the "forloop" as Lothar mentioned x won't get to 1000 until x reaches 1000 but you forgot curl brackets { after the for conditional iteration for(x=1;x<=1000;x++){ // then you are asking to print "cout" after each iteration... I added the "\n"; to address x on each line until you reach 1000 cout<<x<<"\n"; // We need a closing curl bracket for the "forloop" to properly loop } // Then our return 0; with a closing curl bracket for our main return 0; }
29th Nov 2023, 7:56 AM
Aide Pelaez Villa
Aide Pelaez Villa - avatar
0
No 🥳
29th Nov 2023, 7:58 AM
Aide Pelaez Villa
Aide Pelaez Villa - avatar