Present your data with SeaTable on your website with PHP

Now that data is ready: There’s always SOMETHING to do: You have to write the CSS and the PHP, no matter what

You have entered all the data in a nice way in your SeaTable base? Then, it’s time to make a connection to your website. No matter if you are using SQL or SeaTable, you cannot go around this step. Unfortunately, this step requires some knowledge of technologies like PHP.

But anyway, although difficult, it’s still possible, and quite easy for people who are already doing it every day. And the lucky part is: you only have to do it for once. Like SQL, SeaTable offers you the possibility to connect your data (in a safe way, of course) to the internet. In contrast — Excel cannot do that.

We are not going into too many details in this article. So approximately, the CSS of your PHP should look something like this:

This part is identical both for SQL and for SeaTable. And for the part, the difference is also minimal:

For SQL+PHP:

$db = new PDO(‘mysql:host=localhost;dbname=’.$database.’;charset=utf8',$username, $pw);
foreach ($db->query(“SELECT * FROM articles”) as $a){
… Presentation of the article…
}

For SeaTable+PHP:

require_once ‘./seaAPI.php’;
$seatable = new SeafileAPI(array($url,$username,$pw));
$token = $seatable->getDtableToken(‘self-generated-API-TOKEN’);
$rows = $seatable->ListRowsByView($token->dtable_uuid, $token->access_token, $seatable-tabelname);
foreach ($rows as $a){
… Presentation of the article …
}

The rest of PHP in the part is the same. And of course, the webpage output is identical:

Screenshot: Example PHP page output from SQL or SeaTable

Again: in this example, we used PHP as our web technology. You can always use other technologies of your choosing, as SeaTable offers the possibility to retrieve data entries through the SeaTable API.

For your own testing, we are currently preparing a SeaAPI.php and will publish it as soon as possible. By then, you would be able to jump over the programming part!

So what are the advantages and disadvantages of using SeaTable+PHP?

We would like to stress out: to connect your database to a webpage, you always need to do some programming, no matter if you are using SQL or SeaTable. For this part, the programming procedures with SQL or SeaTable API are identical.

The difference only lies in the data collection and management: SeaTable offers online collaboration and easy data collection , as well as rich text fields , and formula fields / customizable scripts to manipulate data, which SQL cannot. Registering to SeaTable is super easy and effortless: one does not need any time or programming knowledge to start using SeaTable, thanks to the intuitive and user-friendly UI design.

And also once again: the SeaTable form is such a powerful tool to collect data from outside your organization. In another article, Realizing Custom Applications with SeaTable Scripts , we have shown you, how easy it is to set up a SeaTable online form and share it with QR-Code or a link to your target group.

As we compare the solutions with SeaTable+PHP and SQL+PHP in this example, we noticed a difference in the time consumed while retrieving data: for the SQL solution, the average retrieving time was 0.003 seconds, and for SeaTable, it was 0.15 seconds.

This was but not a fair comparison! As we set up the SQL on a virtual server and the PHP was in the same box; but for SeaTable, the data was retrieved through the internet. So the internet latency should have been taken into account. If the data load is not immense, this time difference shouldn’t be noticeable by any user.

On the other hand: SeaTable can also be hosted locally so that PHP can retrieve data from its own host. This could have been a different story and a potential game-changer. But anyway, if you have extremely heavy use cases , where data collection, online collaboration, and comfort of use comes in second place, perhaps SQL is still a more efficient choice.

2 Likes

@Karlheinz did you share this php file at the end ?

interesting tips anyway.
some plugins to interact with major CMS publishing tool would be great (eg : wordpress )

Do you mean the SeaAPI.php? No, it’s not ready yet…sorry

Yes, this would be a great starting point.