vknow360
(Sunny Gupta)
November 5, 2019, 1:14pm
#1
Well first of all I would like to say Hi to everyone
Now to move to topic.In this guide I will describe you to make comments system and managing it using your own Database.
What you will need
Here is a list of items/resources you will need before getting started…
How it looks from Designer
Sometimes ago on my one Guide when Aia file download link was not working then users asked for its Design so here is its design…
Components
Following have been used in making this comment system-
Button
TexBox
ChatView
Notifier
Web
Clock
Note:- If you want to show comments in ListView Image and Text then replace ChatView by it
Pre-added rows/tables
If you are continuing this guide then I assume you have created a Table named ‘Comments’ and four rows named as following-
Timestamp
Id
User
Comment
Blocks
Blocks are divided into three parts…
1.Save comment in database
2.Load comments from Datebase
3.Load comments for specific ID
Extras
‘runQuery’ Procedure:-
Thanks to @Taifun
Universal ‘Got Text’ event
Procedure to get ‘id’ for Chat View
Screenshot/Testing
Thanks Peter for your avtar
Apk for testing
Comments.apk (5.1 MB)
Aia File
Here is Aia file download Link:-
Comments.aia (71.6 KB)
Liked my work
You can donate me here:
From Developer
As it is open source so everyone can contribute to this guide and improve it.
Also if you find any bug or have a query then post that here or message me(in personal case)
Thank you
26 Likes
krish.jha
(krishjha07)
November 5, 2019, 2:29pm
#4
Goodwoork
But I already did this in my app but normally…
1 Like
krish.jha
(krishjha07)
November 5, 2019, 2:33pm
#5
I simply stored comments in one cell in database and juth gave each post a different id.and work done!just load Comments according to id
vknow360
(Sunny Gupta)
November 5, 2019, 2:52pm
#6
MySql has more features than airtable.
4 Likes
msr79526
(SR Official)
December 29, 2019, 3:53am
#7
that was awesome but complicated. Can you do that with airtable.& use split block to store more data in one row
1 Like
vknow360
(Sunny Gupta)
December 29, 2019, 11:07am
#8
Actually airtable is easy to use but has less features than mysql.
But I will try.
2 Likes
msr79526
(SR Official)
December 30, 2019, 3:36am
#9
Can you explained what’s the different Between airtable & mysql i mean advantage. I didn’t know.plz
kweng
(Kweng)
December 11, 2021, 10:36am
#10
Airtable database is the simplest way for making comments system like fb, YouTube. I made it comments with airtable.
taqy
(Mohammed taqy)
April 18, 2022, 8:31pm
#11
Hi … i am using infinityfree hosting and i cant find the MySQL DataBase url and also key
please help me .
vknow360
(Sunny Gupta)
April 19, 2022, 2:29pm
#13
Url is your site url while key is what you set in the php file.
For more information see this:
taqy
(Mohammed taqy)
May 8, 2022, 12:03am
#15
Hi , can you give me the php code file
What You’ll Need
Kodular Creator : Use it to design your app’s UI, including the ChatView component for displaying comments.
Web Hosting : Use a hosting service like 000webhost to store and execute PHP scripts.
PHP Script : This will handle communication between your app and the database (e.g., insert, retrieve, delete comments).
Database : A MySQL database hosted on your web server to store the comments.
Steps to Create the Comment System
Step 1: Set Up the Backend
Create a Database :
Log into your web hosting control panel and create a MySQL database.
Create a table for comments with fields like:
sql
Copy code
CREATE TABLE comments (
id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(100),
comment TEXT,
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP
);
Write PHP Scripts :
Insert Comment (insert_comment.php
):
php
Copy code
<?php
$conn = new mysqli("your_host", "your_user", "your_password", "your_database");
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$username = $_POST['username'];
$comment = $_POST['comment'];
$sql = "INSERT INTO comments (username, comment) VALUES ('$username', '$comment')";
if ($conn->query($sql) === TRUE) {
echo "Success";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
?>
Retrieve Comments (get_comments.php
):
php
Copy code
<?php
$conn = new mysqli("your_host", "your_user", "your_password", "your_database");
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT * FROM comments ORDER BY timestamp DESC";
$result = $conn->query($sql);
$comments = array();
while ($row = $result->fetch_assoc()) {
$comments[] = $row;
}
echo json_encode($comments);
$conn->close();
?>
Upload the Scripts :
Use an FTP client or your hosting control panel to upload the PHP scripts to your server.
Step 2: Design the App in Kodular
Add ChatView Component :
Drag the ChatView component onto your screen to display comments.
Create Comment Input Form :
Add a TextBox for the user to input their comment.
Add a Button to submit the comment.
Step 3: Configure Kodular Logic
Retrieve Comments :
Use the Web component to fetch data from get_comments.php
.
On success, parse the JSON response and display comments in the ChatView:
Blocks :
Use Web.GotText
to parse the JSON data.
Use ChatView.AddItem
to display each comment.
Submit Comment :
Use the Web component to send data to insert_comment.php
when the button is clicked.
Pass the username
and comment
as POST parameters.
On success, refresh the comments list by re-calling get_comments.php
.
Step 4: Test the System
Insert Comments :
Test adding comments through the app and check if they appear in the ChatView and database.
Retrieve Comments :
Ensure that comments are retrieved and displayed in real-time.
Error Handling :
Add error messages for failed submissions or network issues.
Optional Enhancements
User Authentication :
Use a login system to associate comments with specific users.
Like/Reply System :
Add functionality to like or reply to specific comments.
Pagination :
Load comments in batches to improve performance with a large number of comments.