there is a table with format entries:

id | A | B | C | D |

so you need to insert, let's say some id on the cycle, in the cell that is not busy! those. let's say if there is data:

0 | 12 | 32 | 43 | 14 | 1 | 54 | 55 |___|___| 

then insert id into the next. empty cell, in this example it is a cell that comes after 55, if all the cells are filled, then you need to make a new record and insert id into the 1st cell of the new record. I hope clearly explained.

  • is the number of columns fixed and constant? - FLK
  • one
    strange task =) - Gorets

1 answer 1

 $q="SELECT * FROM `table` ORDER BY id DESC LIMIT 0,1"; $d=mysql_fetch_array(mysql_query($q),MYSQL_ASSOC); if(is_array($d)){ $id=$d["id"]; foreach($d as $k=>$v){ if(!$v){ if(length($q1))$q1.=", "; $q1.=$k."='".Вставить нужное значение."'"; } } $q1="UPDATE `table` SET ".$q1." WHERE id=".$id; mysql_query($q1); } 

Thus, we filled in the empty fields of incomplete lines, provided that the field id = auto_increment

Then just make direct requests.