How to save a HTML table in MySQL database - efficient way to do this? [closed]

Problem :

I have a php website with a html table. The user is able to modify each of the contained cells (much like in Excel), e.g. change it's content or font-size. My current approach is to save these cells in a one-to-many relationship: One mysql table for the different tables and one mysql table with the cells. To each "table-object" there are several "cell-objects" assigned. The problem I have at the moment is, that this generates really a lot of db querys (about 2200 when saving or opening one table, one for each cell). I think that this really is too much, isn't it (or at least not good way of practice)?

Can anyone give me a hint, what other way I could achieve this? Or is it ok like this anyway?

Thanks in advance,


Solution :

You could probably collect all the cell data into a multidimensional array of cells split into rows:

$table = array(
    array(0, 1, 2, 3, 4, 5),
    array(0, 1, 2, 3, 4, 5),
    array(0, 1, 2, 3, 4, 5)

Then serialize the whole array using PHP serialize() and save it in a single MySQL TEXT field.

When you read from the database, you can just unserialize() the field and it's back to being a normal PHP array which you can loop through and print out the table.

Mysql Tutorials

Mysql Howto..

show the list of selected id in mysql php

how to select records based on recent date in mysql

How to return a MySQL procedure as a trigger?

How to connect MySQL to Java program

How to replace part of my text field in MySQL that has variable number appended

How to perform 'between' in Arabic (hijri) calendar and save it as 'date' in MySQL?

Hello, I am trying to figure out how I can stop my sql script from adding the same value twice into the database

How to filter MySQL results to display LIMIT 1 on per user basis?

How insert 2 related records in mysql

How to determine first instance of multiple items in a table

How to get search a column name from a MySQL database? [duplicate]

How to change default insertion of date format in mysql to d M yy?

How to use apache camel to read data from mysql table and write into another table

How to count occurrences when the gap between the values is greater than x

How to partition Mysql across MULTIPLE SERVERS?

How to refactor these MySQL queries with PHP?

How to pass AJAX results back to requester page

How to specify an auto-incrementing (int) identity column using Fluent-NHibernate and MySQL

MYSQL: How to join two tables using Inner join and then calculatin the total number from the second table for the following examples

How do you detect the issue causes Passenger application instances keeps consuming more and more memory?

How to get mysql to accept sybase database..table notation

How to aggregate/pivot MySQL data over timeline into matrix?

how can you read from database and write to the http stream. php & mysql

How to generate the highest number from one column in mysql database with php

How to have prototype cell pull SQLite rows, and use as MYSQL credentials?

Spring, iBatis, MySQL - how to manage transactions?

how to connect to mysql with visual basic 2010

How to transfer items between users in MySQL safely?

How to set Rank function in hypersql database(HSQLDB)

How to sample rows in MySQL using RAND(seed)?