This section is for posting questions which are not directly related to WYSIWYG Web Builder.
Examples of off topics: web server configuration, hosting, programming related questions, third party scripts.
Note that these questions will generally not be answered by the administrators of this forum.
<?php
echo "DB Test";
// Database connection details
$servername = "";
$username = " ";
$password = "";
$dbname = "";
echo "DB Test connecting";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
echo "DB Test done";
echo $conn;
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "<p>2ID: " . " - title: " . "</p>";
// Write a SQL query to select data from a table
$sql = "SELECT id, title FROM filedownloads";
$result = $conn->query($sql);
// Iterate through the result set and display data
if ($result->num_rows > 0) {
// Output data of each row
while($row = $result->fetch_assoc()) {
echo "<p>ID: " . $row["id"] . " - title: " . $row["title"] . "</p>";
}
} else {
echo "0 results";
}
// Close the connection
$conn->close();
?>
The PHP code is syntactically okay but whether or not it is good PHP is another question.
When I run it I get the following output. DB TestDB Test connecting
First note that this is unrelated to the software.
The code will be inserted "AS IS" , so if it does not work then there is most likely something wrong with the code.
If there is no error in the browser then you can look it up in the PHP error log on the server.
Try to do things correctly if possible as it is database related code so any mistake will lead to information leakage. I hope you know what you are doing.
Last edited by wwonderfull on Thu Oct 17, 2024 10:11 am, edited 1 time in total.
I will need to test this outside of the web builder app.
You should note that you cannot "Preview" php locally in the software you will need to publish to your host/server before you will see the results. Or you will need to install the likes of xampp to set with on your PC.
Looking at the code, I wonder if you can achieve your objective by using one of the Database/Tables extensions (seehttps://www.wysiwygwebbuilder.com/extensions.html) either paid or unpaid. With some you can insert your own MySQL query and you can rely upon the extension to deal with the connection to the database.
I will need to test this outside of the web builder app.
You should note that you cannot "Preview" php locally in the software you will need to publish to your host/server before you will see the results. Or you will need to install the likes of xampp to set with on your PC.
Yes, I know I have to use a web server to run PHP but how cool would it be to be able to preview PHP end result inside WB19?
lummis wrote: ↑Thu Oct 17, 2024 11:42 am
Looking at the code, I wonder if you can achieve your objective by using one of the Database/Tables extensions (seehttps://www.wysiwygwebbuilder.com/extensions.html) either paid or unpaid. With some you can insert your own MySQL query and you can rely upon the extension to deal with the connection to the database.
I did have a look at them but I couldn't see one that was able to list, and display images/URLs/ etc in list view?
thanks
zxspectrum2 wrote: ↑Thu Oct 17, 2024 2:09 pm
I did have a look at them but I couldn't see one that was able to list, and display images/URLs/ etc in list view?
thanks
Do you mean you need something like a dataviewer or a crud where you can see users data and their pictures along with url and other details that sort of thing?