Wednesday, April 23, 2025

JavaScript External, Inline JS

External JavaScript and Internal JavaScript are two ways to include JavaScript code into an HTML document.

External JavaScript is when the JavaScript code is stored in a separate file with a .js extension and then linked to the HTML document using the script tag with the src attribute. This means that the JavaScript code is not included within the HTML document but is instead stored separately in a file. This method allows for better code organization and reusability since the same JavaScript file can be linked to multiple HTML documents.

Internal JavaScript is when the JavaScript code is included directly in the HTML document between the script tags. This method allows for quick and simple JavaScript code, but can make the HTML document larger and harder to read, especially when there is a lot of JavaScript code. 

In general, it's recommended to use external JavaScript files as much as possible for better code organization and reusability. Internal JavaScript can be used for small scripts that only need to be used on a single page.


<!DOCTYPE html>
<html>
<head>

<script src="main.js"></script>

</head>

<body>

<script>

	document.write("Hack The Planet");
	document.write("<br><br><br>");
	document.write("Mess with the best, die like the rest");

</script>
	
</body>
</html>

This HTML code defines a web page that includes an external JavaScript file main.js. The file path is specified in the src attribute of the <script> tag in the <head> section of the HTML document. The main.js file contains the JavaScript code that will be executed in the web page.

The code inside the <script> tag in the <body> section of the HTML document writes two lines of text on the web page using the document.write() method.

When the web page is loaded, the browser will parse the HTML and load the external main.js file, which will be executed on the client side. However, the main.js file is not included in this code snippet, so its content and behavior are unknown.

Content of main.js file:


alert("I am from External File");

Inline JavaScript for Google Link


<body>

<script>

	document.write("Hack The Planet");
	document.write("<br><br><br>");
	document.write("Mess with the best, die like the rest");

</script>

<ul>
	<li><a onclick="alert('I am from Inline')" href="https://google.com">Google</a></li>
	<li><a href="https://yahoo.com">Yahoo</a></li>
</ul>
	
</body>

This code creates an unordered list (<ul>) with two list items (<li>) that contain hyperlinks (<a>) to Google and Yahoo.

The first hyperlink has an onclick attribute which executes a JavaScript alert that displays the message "I am from Inline" when the link is clicked. The second hyperlink does not have any onclick attribute.

When the user clicks on the first hyperlink to Google, an alert pop-up with the message "I am from Inline" will appear before the user is redirected to the Google website. The second hyperlink to Yahoo will simply redirect the user to the Yahoo website.

JavaScript Alerts, PopUp Boxes


<!DOCTYPE html>

<html>
<head>
</head>
<body>
<script>
	document.write("Hack The Planet");
	document.write("<br><br><br>");
	document.write("Mess with the best, die like the rest");
</script>

<script>
	alert("I will Jump on Page Load");
</script>
	
</body>
</html>

This HTML code creates a web page with two JavaScript scripts.

The first script contains three lines of code that use the document.write() method to write text to the web page. The first line writes "Hack The Planet", and the two <br> tags create two blank lines of space between the text. The second line writes "Mess with the best, die like the rest".

The second script contains a single line of code that uses the alert() method to display a pop-up message with the text "I will Jump on Page Load". This pop-up message will appear when the web page finishes loading in the browser. 


<script>
	alert("First Pop-Up");
	alert("Second Pop-Up");
</script>

This JavaScript code will display two popup windows with messages "First Pop-Up" and "Second Pop-Up" respectively. When the script is executed, the first alert box will appear, and after the user closes it, the second alert box will appear. The user needs to click the "OK" button to close each alert box.

JavaScript Doctype, Functions


<!DOCTYPE html>

<html>
<head>
</head>

<body>

<script>

	document.write("Hack The Planet");
	document.write("<br><br><br>");
	document.write("Mess with the best, die like the rest");

</script>
	
</body>
</html>

This is an HTML file that contains JavaScript code that writes text on the web page.

The <!DOCTYPE html> is an HTML5 document type declaration, indicating that the document is an HTML5 document.

The <html> tag encloses the entire HTML document.

The <head> section contains metadata about the document, but in this case, it is empty.

The <body> tag contains the content of the web page, including the JavaScript code.

The <script> tag is used to embed JavaScript code within an HTML document. The code inside the <script> tags will be executed by the browser.

The document.write() method writes text to the HTML document. In this case, it is used to write "Hack The Planet" and "Mess with the best, die like the rest" on separate lines, with three line breaks between them.

When the web page is loaded, the JavaScript code is executed, and the text "Hack The Planet" and "Mess with the best, die like the rest" are displayed on the web page.

JavaScript Server Setup, First Script


<!DOCTYPE html>
<html>
<head>
</head>
<body>

<script type="text/javascript">

	document.write("Hack The Planet");

</script>

</body>
</html>

This is a simple HTML page with a JavaScript script embedded in the <head> tag. The script uses the document.write() method to display the string "Hack The Planet" on the page.

When the page is loaded in a web browser, the script will run and the string "Hack The Planet" will be displayed on the page. This is a very basic example of using JavaScript to manipulate the contents of an HTML page.

JavaScript Introduction

MySQLi Finishing Pure PHP CMS

update_all.html


<form action="update_all_script.php" method="post">
<label>ID</label><br>
<input type="text" name="id">
<br><br>

<label>Name</label><br>
<input type="text" name="name">
<br><br>

<label>Last Name</label><br>
<input type="text" name="lastname">
<br><br>

<label>Telephon</label><br>
<input type="text" name="telephon">
<br><br>

<label>email</label><br>
<input type="text" name="email">
<br><br>

<label>Address</label><br>
<input type="text" name="address">
<br><br>

<input type="submit" value="Submit">
</form>

This is an HTML form that allows a user to input data for updating a record in a MySQL database table. The form has fields for ID, name, last name, telephone, email, and address. When the form is submitted, the data is sent to a PHP script for processing.

The PHP script will receive the data submitted by the form via the $_POST superglobal variable. It will then establish a connection to the MySQL server using the given credentials and database name. The script will then construct an SQL command to update the record in the table using the ID specified in the form. The SQL command will update all columns in the table for the specified ID.

If the SQL command executes successfully, the script will display a message indicating success. If an error occurs during the execution of the SQL command, the script will display an error message containing the error description returned by MySQL.

update_all_script.php


<?php

$id = $_POST["id"];
$name = $_POST["name"];
$lastname = $_POST["lastname"];
$telephon = $_POST["telephon"];
$email = $_POST["email"];
$address = $_POST["address"];

//Config

$server = "localhost";
$user = "root";
$password = "";
$database = "address_book";

//Establishing a Connection to MySQL Server
$connection = mysqli_connect($server, $user, $password, $database);

//Check Connection
if (!$connection) {
	die("<h2>Total Fail</h2> " . mysqli_connect_error());
} else {
	echo "Connection Successfull <br>";
}

//SQL Command
$sql_command = "UPDATE people SET 
name = '$name',
lastname = '$lastname',
telephon = '$telephon',
email = '$email',
address = '$address' WHERE id = '$id'";

if (mysqli_query($connection, $sql_command)) {
	echo "SQL Command OK";	
} else {
	echo "SQL Error " . mysqli_error($connection) ;
}

?>

This PHP script updates the information of a person in an address book stored in a MySQL database. It receives the new information through a form submitted with the POST method, and uses the values provided to update the fields of the corresponding person in the database.

The script connects to the MySQL server and checks the connection. If the connection is successful, it builds an SQL command to update the values of the person with the specified ID. If the SQL command is executed successfully, the script outputs "SQL Command OK". Otherwise, it outputs an error message with the reason for the failure.

When you run it with new data:


Connection Successfull
SQL Command OK

Always check entries with html_table_report.php

 

Navigation - general structure for php include or html hardcoding

<a href="html_table_report.php">Home - Report</a> |
<a href="html_form_to_table.html">New Post</a> |
<a href="delete_by_id.html">Delete by ID</a> |
<a href="update_all.html">Update by ID</a><br><br>

This is a navigation menu in HTML that includes links to different pages or actions related to an address book application. The links are:

  • Home - Report: this link goes to the "html_table_report.php" page, which likely displays a table with data from the address book.
  • New Post: this link goes to the "html_form_to_table.html" page, which likely displays a form to add a new entry to the address book.
  • Delete by ID: this link goes to the "delete_by_id.html" page, which likely displays a form to delete a specific entry from the address book by ID.
  • Update by ID: this link goes to the "update_all.html" page, which likely displays a form to update a specific entry from the address book by ID.

Report/Listing on every php or html page (remove part for connection if connection is already established) - it's same code as in html_table_report.php


<?php
//Config

$server = "localhost";
$user = "root";
$password = "";
$database = "address_book";

//Establishing a Connection to MySQL Server
$connection = mysqli_connect($server, $user, $password, $database);

//Check Connection
if (!$connection) {
	die("<h2>Total Fail</h2> " . mysqli_connect_error());
} else {
	echo "Connection Successfull <br>";
}

//SQL Command
$sql_command = "SELECT * FROM people";
$action = mysqli_query($connection, $sql_command);

echo "<h1>Results: </h1>";
echo "<table width='80%' cellspan='2' border='2'><tr bgcolor='yellow'>";
echo "<td>ID</td>";
echo "<td>Name</td>";
echo "<td>Lastname</td>";
echo "<td>Telephon</td>";
echo "<td>email</td>";
echo "<td>Address</td>";
echo "<td>Data/Time</td></tr>";

while ($line = mysqli_fetch_assoc($action)) {
	echo "<tr><td>" . $line["id"] . "</td>
	<td>" . $line["name"] . "</td>
	<td>" . $line["lastname"] . "</td>
	<td>" . $line["telephon"] . "</td>
	<td>" . $line["email"] . "</td>
	<td>" . $line["address"] . "</td>
	<td>" . $line["meta"] . "</td>";
	
}
echo "</table>";

?>

This PHP script is used to display the results of a MySQL query on a webpage in the form of an HTML table.

It first sets up the connection to a MySQL server using the given configuration parameters. It then constructs a SELECT query that fetches all rows from the "people" table in the specified database.

After executing the query, it prints an HTML table with headers for each column in the table. It then loops through each row returned by the query and prints out the values for each column in that row. Each row is represented as an HTML table row, and each column is represented as an HTML table data cell.

Finally, it closes the HTML table and outputs it to the webpage.

MySQLi Delete by ID

delete_by_id.html


<form action="delete_id.php" method="post">
<label>ID To Delete</label><br>
<input type="text" name="id_to_delete">
<br><br>

<input type="submit" value="Submit">
</form>

This form is used to delete a record from the database. It asks for the ID of the record to be deleted and has a submit button. When the form is submitted, it sends the data to a PHP script located at "delete_id.php" using the HTTP POST method.

delete_id.php


<?php
//Config

$server = "localhost";
$user = "root";
$password = "";
$database = "address_book";

$get_id_to_delete = $_POST["id_to_delete"];

//Establishing a Connection to MySQL Server
$connection = mysqli_connect($server, $user, $password, $database);

//Check Connection
if (!$connection) {
	die("<h2>Total Fail</h2> " . mysqli_connect_error());
} else {
	echo "Connection Successfull <br>";
}

//SQL Command
$sql_command = "DELETE FROM people WHERE id=$get_id_to_delete";

if (mysqli_query($connection, $sql_command)) {
	echo "SQL Command OK";	
} else {
	echo "SQL Error " . mysqli_error($connection) ;
}

?>

This PHP script connects to a MySQL server and receives a POST variable called "id_to_delete" from a form.

It then constructs a SQL command to delete a row from the "people" table where the ID matches the value of the POST variable. If the SQL command is successful, it displays the message "SQL Command OK".

If there is an error, it displays the error message using the mysqli_error() function. The script assumes that the database configuration values are correct and the connection to the database server is successful.

If you submit existing ID to delete:


Connection Successfull
SQL Command OK

Check html_table_report.php to see what's in database now.

MySQLi Admin Panel

You are strongly advised to check this YouTube tutorial to fully understand our cms and custom admin panel:

MySQLi Html Form to Table

html_form_to_table.html


<form action="data_insert.php" method="post">
<label>Name</label><br>
<input type="text" name="name">
<br><br>

<label>Last Name</label><br>
<input type="text" name="lastname">
<br><br>

<label>Telephon</label><br>
<input type="text" name="telephon">
<br><br>

<label>email</label><br>
<input type="text" name="email">
<br><br>

<label>Address</label><br>
<input type="text" name="address">
<br><br>

<input type="submit" value="Submit">
</form>

This is an HTML form that allows a user to input data to be inserted into a database table. The form uses the POST method to send the data to a script called "data_insert.php" for processing.

The form contains the following input fields:

  • Name: a text field for the user's first name
  • Last Name: a text field for the user's last name
  • Telephon: a text field for the user's telephone number
  • email: a text field for the user's email address
  • Address: a text field for the user's address

There is also a "Submit" button that the user can click to submit the form data.

data_insert.php


<?php
$name = $_POST["name"];
$lastname = $_POST["lastname"];
$telephon = $_POST["telephon"];
$email = $_POST["email"];
$address = $_POST["address"];
//Config

$server = "localhost";
$user = "root";
$password = "";
$database = "address_book";

//Establishing a Connection to MySQL Server
$connection = mysqli_connect($server, $user, $password, $database);

//Check Connection
if (!$connection) {
	die("<h2>Total Fail</h2> " . mysqli_connect_error());
} else {
	echo "Connection Successfull <br>";
}

//SQL Command
$sql_command = "INSERT INTO people (id, name, lastname, telephon, email, address)
VALUES (NULL, '$name', '$lastname', '$telephon', '$email', '$address')";

if (mysqli_query($connection, $sql_command)) {
	echo "SQL Command OK";	
} else {
	echo "SQL Error " . mysqli_error($connection) ;
}

?>

This PHP code establishes a connection to a MySQL server and inserts the values from the HTML form into the people table using an INSERT INTO SQL command.

Just make sure that the database connection details (server, user, password, database) are correct and that the people table exists in the database.

After we submit some data:


Connection Successfull
SQL Command OK

And when we check html_table_report.php:


Connection Successfull
Results:
ID	Name	Lastname	Telephon	email	Address	Data/Time
1	Slavoj	Zizek	222555	slavojzizek@someserver.com	Slavoj Zizek 123	2020-07-25 15:34:45
2	Jordan	Peterson	888454	jordan@server.com	Jordan P. 234	2020-07-25 15:35:43

MySQLi Truncate Table

delete_all.php 


<?php
//Config

$server = "localhost";
$user = "root";
$password = "";
$database = "address_book";

//Establishing a Connection to MySQL Server
$connection = mysqli_connect($server, $user, $password, $database);

//Check Connection
if (!$connection) {
	die("<h2>Total Fail</h2> " . mysqli_connect_error());
} else {
	echo "Connection Successfull <br>";
}

//SQL Command
$sql_command = "TRUNCATE TABLE people";

if (mysqli_query($connection, $sql_command)) {
	echo "SQL Command OK";	
} else {
	echo "SQL Error " . mysqli_error($connection) ;
}

?>

This SQL command will delete all the data from the people table in the connected database.

The TRUNCATE TABLE command is used to delete all rows from a table while keeping its structure intact. So, in this case, the table structure (columns and data types) will still be there, but all the data will be deleted.

If the command is successful, it will output "SQL Command OK", otherwise it will output "SQL Error" along with the error message generated by MySQL.

When we run it, all rows are gone.


Connection Successfull
SQL Command OK

MySQLi Update Statement

update_statement.php


<?php
//Config

$server = "localhost";
$user = "root";
$password = "";
$database = "address_book";

//Establishing a Connection to MySQL Server
$connection = mysqli_connect($server, $user, $password, $database);

//Check Connection
if (!$connection) {
	die("<h2>Total Fail</h2> " . mysqli_connect_error());
} else {
	echo "Connection Successfull <br>";
}

//SQL Command
$sql_command = "UPDATE people SET telephon=888999 WHERE name='John'";

if (mysqli_query($connection, $sql_command)) {
	echo "SQL Command OK";	
} else {
	echo "SQL Error " . mysqli_error($connection) ;
}

?>

This SQL command updates the "telephon" field for the row(s) where the "name" field is equal to "John". Specifically, it sets the "telephon" field to 888999 for all rows where the "name" field is "John". If the query is successful, the message "SQL Command OK" is displayed. Otherwise, the error message returned by mysqli_error() is displayed.

When we run it:


Connection Successfull
SQL Command OK

MySQLi Delete From Table

delete_from_table.php


<?php
//Config

$server = "localhost";
$user = "root";
$password = "";
$database = "address_book";

//Establishing a Connection to MySQL Server
$connection = mysqli_connect($server, $user, $password, $database);

//Check Connection
if (!$connection) {
	die("<h2>Total Fail</h2> " . mysqli_connect_error());
} else {
	echo "Connection Successfull <br>";
}

//SQL Command
$sql_command = "DELETE FROM people WHERE id=3";

if (mysqli_query($connection, $sql_command)) {
	echo "SQL Command OK";	
} else {
	echo "SQL Error " . mysqli_error($connection) ;
}

?>

This SQL command will delete a row from the people table in the database where the id value is equal to 3. If the SQL command is executed successfully, the message "SQL Command OK" will be displayed. If there is an error, the message "SQL Error" along with the error message will be displayed.

After we run script once for that specific ID:


Connection Successfull
SQL Command OK

MySQLi Html Table Report

html_table_report.php


<?php
//Config

$server = "localhost";
$user = "root";
$password = "";
$database = "address_book";

//Establishing a Connection to MySQL Server
$connection = mysqli_connect($server, $user, $password, $database);

//Check Connection
if (!$connection) {
	die("<h2>Total Fail</h2> " . mysqli_connect_error());
} else {
	echo "Connection Successfull <br>";
}

//SQL Command
$sql_command = "SELECT * FROM people";
$action = mysqli_query($connection, $sql_command);

echo "<h1>Results: </h1>";
echo "<table width='80%' cellspan='2' border='2'><tr bgcolor='yellow'>";
echo "<td>ID</td>";
echo "<td>Name</td>";
echo "<td>Lastname</td>";
echo "<td>Telephon</td>";
echo "<td>email</td>";
echo "<td>Address</td>";
echo "<td>Data/Time</td></tr>";

while ($line = mysqli_fetch_assoc($action)) {
	echo "<tr><td>" . $line["id"] . "</td>
	<td>" . $line["name"] . "</td>
	<td>" . $line["lastname"] . "</td>
	<td>" . $line["telephon"] . "</td>
	<td>" . $line["email"] . "</td>
	<td>" . $line["address"] . "</td>
	<td>" . $line["meta"] . "</td>";
	
}
echo "</table>";

?>

This PHP code will retrieve all the data from the "people" table in the MySQL database and display it in an HTML table.

The code first runs a SQL SELECT query to retrieve all the data from the "people" table. Then, it uses a while loop and mysqli_fetch_assoc() function to retrieve each row of data one at a time. For each row, it echoes an HTML table row with the data from the columns, enclosed in table cells.

The table structure is defined at the beginning of the loop, and the table cells are populated with the values from the query results.

At the end of the loop, the PHP code closes the HTML table tag. The resulting output will be an HTML table showing all the data from the "people" table.

Nice Html Table Report:


Connection Successfull
Results:
ID	Name	Lastname	Telephon	email	Address	Data/Time
1	Samantha	Fox	555444	mail@server.com	Main Road 12a	2020-07-25 12:01:51
2	Samantha	Fox	555444	mail@server.com	Main Road 12a	2020-07-25 12:04:28
3	Samantha	Fox	555444	mail@server.com	Main Road 12a	2020-07-25 12:04:29

MySQLi Select All

select_all.php


<?php
//Config

$server = "localhost";
$user = "root";
$password = "";
$database = "address_book";

//Establishing a Connection to MySQL Server
$connection = mysqli_connect($server, $user, $password, $database);

//Check Connection
if (!$connection) {
	die("<h2>Total Fail</h2> " . mysqli_connect_error());
} else {
	echo "Connection Successfull <br>";
}

//SQL Command
$sql_command = "SELECT * FROM people";
$action = mysqli_query($connection, $sql_command);

while ($line = mysqli_fetch_assoc($action)) {
	echo "ID: " . $line["id"] . "<br>";
}

?>

The above PHP code executes an SQL SELECT statement to retrieve all data from the "people" table and prints the "id" field for each record retrieved using a while loop.

Here is an explanation of each line:

  • $sql_command = "SELECT * FROM people"; - This sets the SQL command to select all data from the "people" table.
  • $action = mysqli_query($connection, $sql_command); - This executes the SQL command on the database using the established connection and stores the result in the $action variable.
  • while ($line = mysqli_fetch_assoc($action)) { - This starts a while loop that runs as long as there are rows in the result set to be processed.
  • echo "ID: " . $line["id"] . "<br>"; - This prints the "id" field value of the current row in the result set to the screen, with some HTML formatting.
  • } - This ends the while loop.

Note that this code could be extended to print out more fields or to process the data in some other way.

Initial report with just IDs is ok:


Connection Successfull
ID: 1
ID: 2
ID: 3
ID: 4
ID: 5
...
ID: 24
ID: 25
ID: 26

select_all_2.php


<?php
//Config

$server = "localhost";
$user = "root";
$password = "";
$database = "address_book";

//Establishing a Connection to MySQL Server
$connection = mysqli_connect($server, $user, $password, $database);

//Check Connection
if (!$connection) {
	die("<h2>Total Fail</h2> " . mysqli_connect_error());
} else {
	echo "Connection Successfull <br>";
}

//SQL Command
$sql_command = "SELECT * FROM people";
$action = mysqli_query($connection, $sql_command);

while ($line = mysqli_fetch_assoc($action)) {
	echo "ID: " . $line["id"] . "<br>";
	echo "Name: " . $line["name"] . "<br>";
	echo "Lastname: " . $line["lastname"] . "<br>";
	echo "Telephone: " . $line["telephon"] . "<br>";
	echo "email: " . $line["email"] . "<br>";
	echo "Address: " . $line["address"] . "<br>";
	echo "Date/Time: " . $line["meta"] . "<br>";
	echo "<hr>";
}

?>

This PHP code performs the following tasks:

  1. Define a SQL command to select all columns from the table "people".
  2. Execute the SQL command using the mysqli_query() function, which returns a result set.
  3. Loop through each row in the result set using the mysqli_fetch_assoc() function.
  4. For each row, print out the values of each column in the row, using associative array keys to access the values.
  5. Separate each row with a horizontal rule ("<hr>").

Small part of report for first ID:


Connection Successfull
ID: 1
Name: Samantha
Lastname: Fox
Telephone: 555444
email: mail@server.com
Address: Main Road 12a
Date/Time: 2020-07-25 12:01:51
...

select_all_3.php


<?php
//Config

$server = "localhost";
$user = "root";
$password = "";
$database = "address_book";

//Establishing a Connection to MySQL Server
$connection = mysqli_connect($server, $user, $password, $database);

//Check Connection
if (!$connection) {
	die("<h2>Total Fail</h2> " . mysqli_connect_error());
} else {
	echo "Connection Successfull <br>";
}

//SQL Command
$sql_command = "SELECT * FROM people";
$action = mysqli_query($connection, $sql_command);

while ($line = mysqli_fetch_assoc($action)) {
	echo "ID: " . $line["id"] . 
	"Name: " . $line["name"] . 
	"Lastname: " . $line["lastname"] . 
	"Telephone: " . $line["telephon"] . 
	"email: " . $line["email"] . 
	"Address: " . $line["address"] . 
	"Date/Time: " . $line["meta"]
	. "<hr>";
}

?>

Part of report:


Connection Successfull
ID: 1 Name: Samantha Lastname: Fox Telephone: 555444 email: mail@server.com Address: Main Road 12a Date/Time: 2020-07-25 12:01:51
ID: 2 Name: Samantha Lastname: Fox Telephone: 555444 email: mail@server.com Address: Main Road 12a Date/Time: 2020-07-25 12:04:28
ID: 3 Name: Samantha Lastname: Fox Telephone: 555444 email: mail@server.com Address: Main Road 12a Date/Time: 2020-07-25 12:04:29

MySQLi Multiple Insert

multiple_inserts.php


<?php
//Config

$server = "localhost";
$user = "root";
$password = "";
$database = "address_book";

//Establishing a Connection to MySQL Server
$connection = mysqli_connect($server, $user, $password, $database);

//Check Connection
if (!$connection) {
	die("<h2>Total Fail</h2> " . mysqli_connect_error());
} else {
	echo "Connection Successfull <br>";
}

//SQL Command
$sql_command = "INSERT INTO people (id, name, lastname, telephon, email, address)
VALUES (NULL, 'John', 'Smith', 555777, 'mailx@server.net', 'Main Road 12a');";

$sql_command .= "INSERT INTO people (id, name, lastname, telephon, email, address)
VALUES (NULL, 'Samantha', 'Smith', 111222, 'mailz@server.net', 'Main Road 12a');";

$sql_command .= "INSERT INTO people (id, name, lastname, telephon, email, address)
VALUES (NULL, 'Anabela', 'Smith', 555777, 'mailx@server.net', 'Main Road 12a')";

//Check SQL Command
if (mysqli_multi_query($connection, $sql_command)) {
	$last_entry = mysqli_insert_id($connection);
	echo "SQL Command OK, Last ID: " . $last_entry . "<hr>" ;
} else {
	echo "SQL ERROR" . mysqli_error($connection);
}

?>

This PHP code creates a SQL command that inserts multiple rows into the people table of the currently selected database.

The $sql_command variable is a string that concatenates multiple INSERT statements together.

Each INSERT statement specifies the columns and values to be inserted into the table. The id column is set to NULL, which will automatically generate a new value for this column using the AUTO_INCREMENT feature.

The mysqli_multi_query() function is used to execute the SQL command. If the command is successful, the mysqli_insert_id() function is used to retrieve the ID of the last inserted row.

The output will be either "SQL Command OK, Last ID: [ID]" if the command was successful or "SQL ERROR" if there was an error executing the command.

After we run it multiple times:


Connection Successfull
SQL Command OK, Last ID: 24

Tkinter Introduction - Top Widget, Method, Button

First, let's make shure that our tkinter module is working ok with simple  for loop that will spawn 5 instances of blank Tk window .  ...