Okie im working on this RPG based game for a forum...
It uses MySQL Tables, I have it set up so each charecter has a different ID.... 1, 2, 3, 4,5.... and so on
Now my problem is, the way I have it coded if a user deleats thier charecter, then there will be a problem, Because I have it set up to count the number of rows then add one to get the new ID...
Im trying to figure out a way to count the number of rows add one, AND THEN CHECK IF THAT NUMBER IF IS ALREADY IN USE, and if its not use it, if it is, add one and try again.....
i was thinking i could use sum kind of loops to try and do this, but Ive come up blank....
here is sum of the code im dealing with
$DB->query("SELECT id FROM ibcharecter");
$Num = $DB->get_num_rows();
$Count = $Num + 1;
$DB->query("INSERT INTO rpWcharecter VALUES ($Count, $othervariables)");
I tried this test code to see if I could explode the $Row array to check each one, but it didnt work
$DB->query("SELECT id FROM ibcharecter");
$Row = $DB->fetch_row();
$Bob = explode("\\", $Row);
if ($Bob['0'] == 1) {
echo "True<Br>";
} else {
echo "False<br>";
}
if ($Bob['1'] == 2) {
echo "True<Br>";
} else {
echo "False<br>";
}
if ($Bob['2'] == 3) {
echo "True<Br>";
} else {
echo "False<br>";
}
if ($Bob['3'] == 4) {
echo "True<Br>";
} else {
echo "False<br>";
}
I know about the autoincrement feature in mysql...... that seems to be a good idea, but I really dont know how to get it to work.....
I tried to change my tables stuff via phpmyadmin to autoincrement...but it came up with an error.....
Any ideas guys?