I have this problem... let's start with the code.
$finalkey = $mainkey + '9';
$mainkeystay = $mainkey;
$hold1 = 'NA';
$hold2 = 'NA';
$hold3 = 'NA';
$hold4 = 'NA';
$hold5 = 'NA';
$hold6 = 'NA';
$hold7 = 'NA';
$hold8 = 'NA';
$hold9 = 'NA';
while ( $finalkey > $mainkey )
{
//we make an array, called $row, from our SQL DB where our key matches $mainkey
$str = "SELECT * FROM `prop_data` WHERE `key`='$mainkey' AND `deleted`='0' LIMIT 9";
$query = $db->query($str);
$row = $db->arr($query);
// $hold{$mainkey} = implode(",", $row);
if ( empty($mainkey) )
{$mainkey++;}
elseif ( $mainkey == $mainkeystay)
{$hold1 = implode(",", $row);}
//--- key 1
elseif ( $mainkey == $mainkeystay + '1' )
{$hold2 = implode(",", $row);}
//--- key 2
elseif ( $mainkey == $mainkeystay + '2' )
{$hold3 = implode(",", $row);}
//--- key 3
elseif ( $mainkey == $mainkeystay + '3' )
{$hold4 = implode(",", $row);}
//--- key 4
elseif ( $mainkey == $mainkeystay + '4' )
{$hold5 = implode(",", $row);}
//--- key 5
elseif ( $mainkey == $mainkeystay + '5' )
{$hold6 = implode(",", $row);}
//--- key 6
elseif ( $mainkey == $mainkeystay + '6' )
{$hold7 = implode(",", $row);}
//--- key 7
elseif ( $mainkey == $mainkeystay + '7' )
{$hold8 = implode(",", $row);}
//--- key 8
elseif ( $mainkey == $mainkeystay + '8' )
{$hold9 = implode(",", $row);}
//--- key 9
$mainkey++;
}
now, the problem is that i'm just counting $mainkey. What I need to do is check $mainkey versus the MySQL db and see if that number exists anywhere within the database - if it doesnt, increase it by one, and check. if not, increase it by one more, ect, till it either finds a valid one, or tries about lets say, 18 times? and then make it stop. Any way to do this? :/ (obviously, the $mainkey can be like, 1, 3, 4, 15, 21, ect :/)
I have an ID row in MySQL that's on auto increment, and when I 'delete' entries, i just use a deleted flag..