R
R
Rishat Sultanov2017-05-01 21:51:48
MySQL
Rishat Sultanov, 2017-05-01 21:51:48

What's wrong with fetching data from a database?

Good afternoon, ladies and gentlemen.
There is a database and one table in it, where we have only ids.
By which I upload them to the page in the form of a form.
Next, I made a system for deleting data by ID.
But the data loses the unloading algorithm in 4 blocks. At least according to the algorithm, they should be scattered as they were originally. If you just add data to the table. Unloading according to this algorithm works with a bang, but as soon as I delete not the last number. I see the error right away. Since the data does not start to run through the algorithm again.
The site where the code is running- Here the blocks remain empty if you delete elements.
And they should work according to the algorithm that is written in the get () function.
What's wrong? Tell me please!
The algorithm is:
1) Get the number of elements in the table
2) Divide by 4 to calculate the remainder - writing it to a variable.
3) We throw 3 blocks with the result of division by 4 and only the last 4 block receives, in addition to the result of division by 4, also the remainder.

I wrote such an algorithm, maybe it’s very stupid for someone :) But my head didn’t think of more :) If you took off your slippers, please put it back on and, if possible, describe your algorithm for spreading data into 4 blocks :)
Thank you all for your help :)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
B
Boris Korobkov, 2017-05-01
@rishatss

Option 1. After deletion, renumber all remaining entries. In the same id field or create a new one.
Option 2. Display and delete not by id, but by sequence. For selection/grouping/display use array index. And to delete, for example, the 5th sheep DELETE FROM ... WHERE id = (SELECT id FROM ... LIMIT 5, 1). If MySQL, then two different queries.

V
Vadim, 2017-05-02
@Folour

Looked at the code. It's like being back in 2009. He's terrible.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question