Run SQL Script
Page to run a SQL Script.
Has NOINDEX Meta - as I don't want it to be found out of context. Google tracking is also removed as I don't wnat multiple entries in the reports as this page will have to be loaded many times to debug the scripts.
Initially the scripts will be based on the PHP scripts that I have working previously
The PHP SQL will be replaced on the page as required. The output is echoed to the screen using simple PHP ECHO. Eventually I want this to be formatted to a page based on the current format.
Button above will replace "Run Script".
Run Script
Populate from mySQL:
The PHP file is: demo_db_select_pdo.php (this will be replace appropriately)
The SELECT script runs - next step is the table create script - what happens when you try to create a table that already exists? The PHP SQL script contains error-checking -- for the SELECT it is the number of rows. A CREATE is not successful may another error. (doing some research it looks like the statement does not return a value)
The SQL statement is the PHP variable $sql in the PHP script.
Documentation
I have improved this considerably since I started the project. However, I don't think that I can highlight SQL. Maybe PHP????? - Looking for this I came across the w3-filter class, which could be useful for filtering search results.
A simple connect and echo table contents.
The SELECT PHP is:
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "
id: ". $row["id"]. " - Name: ". $row["firstname"]. " " . $row["lastname"] . "
"; }
} else {
echo "0 results";
}
The population of an HTML table from the result of a query
I may have done this before, but I can bet that there are some examples out there!
This example does this https://tryphp.w3schools.com/showphpfile.php?filename=demo_db_select_pdo
CREATE TABLE
create1.php
INSERT
This is the current script being developed