0

Hi all,

I need to do my own version of phpMyAdmin for my php class. I encountered problem when trying modify existing data on database. I don't know what would be best way to modify whole table's data when I don't know exact amount of rows or columns. At this point I list existing table to <input type=text> and have also hidden inputs for delivering data to my updater php file. But what would be best way to actually update data to database. Do I just loop through all data and update it one by one or in a one big sql query or what? I don't want you guys to do this for me so no need for ready code, only the general idea.

Thanks in an advance.

Edit. Just realized I don't need that hidden input really for anything so that's gone but main problem still exists.

Edited by Viped: Update

3
Contributors
4
Replies
18
Views
3 Years
Discussion Span
Last Post by diafol
0

You get the number of fields and number of records from the SQL query.
You create a table dynamically through php.

I would suggest some ajax / javascript in order to create an editable row - which places data of that record into textboxes / selects and adds an update button.

Also limit data retrieved with LIMIT clause to say 50 records and use pagelinks/pagination.

0

What about displaying, for example, no more than 50 records per page, so that a maximum of 50 rows will be updated at a time?

And then about updating a large amount of rows: each row contains data that is unique to that row, so you will probably have to run a query for each row. You modify a row by its primary key, which means each row will need to be updated separately. Except, of course, if changing the values of all rows at once.

0

I love this site. I always get great answers when I ask something. So thanks again. That limiting is good idea (how didn't I figure it out by myself). Now I probably can have one big dynamically created query or just loop all one by one either way it probably won't be too slow to execute. For javascript part I will definetely use that for data validation but the core functions need to be working on also on browsers which have JS disabled.

0

Browsers with js disabled are few and far between these days, but, in the event of js not being available, you can fall back (degrade gracefully) to the old "edit" button next to a row, like the monstrous phpmyadmin, which would send you to an edit record page. The js-enabled browser would let you edit in-situ.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.