hi
i am working on a simple mysql app in b4j
i am getting/sending data to php script and then to mysql db
i also delete and insert new entries, the question is, after deleting an entry i would like to give all entries again an id (int 0 to ...)
like:
(entries
0 | ilan | 34
1 | david | 72
2 | michael | 52
...
if i delete entry 2 (1 | david | 72) i want to renumber again all other entries from 0 to MAX
i do it like this:
but this is wrong because if i have 2 (or more) entries with the same name i will have for both the same id
so what is the right way to do it??
another question can i just edit an entry with a specific index and not id??
like delete entry in index 2 ...
thanx
i am working on a simple mysql app in b4j
i am getting/sending data to php script and then to mysql db
i also delete and insert new entries, the question is, after deleting an entry i would like to give all entries again an id (int 0 to ...)
like:
(entries
0 | ilan | 34
1 | david | 72
2 | michael | 52
...
if i delete entry 2 (1 | david | 72) i want to renumber again all other entries from 0 to MAX
i do it like this:
B4X:
case "ReNumberPersons":
$q = mysql_query("SELECT name FROM '$table'");
$rows = array();
$id = 0;
while($r = mysql_fetch_assoc($q))
{
$rows[] = $r;
}
foreach ($rows as $r) {
mysql_query("UPDATE '$table' SET id = '$id' WHERE name = '$r[name]'");
$id = $id + 1;
}
print "ReNumberDone";
break;
but this is wrong because if i have 2 (or more) entries with the same name i will have for both the same id
so what is the right way to do it??
another question can i just edit an entry with a specific index and not id??
like delete entry in index 2 ...
thanx