Hi
I swear i've done this before but I can't remember how. I'm trying to loop a query in a database. The query counts the results. When the result doesn't equal 1 (or greater than 1) the result is outputted.
For example.
database entried
ID | Value
1 | bbaa
2 | bbab
3 | bbac
4 | bbad
the first two values (bb) are constant, the second two (aa, ab, ac, etc.) always change.
Therefore. I'm trying to query the database and find out which would be the next entry in the sequence.
I'm trying something like this:
$contstant = "bb" //always stays bb
$var = "aa"; //always starts aa
for($num=1; $num<1; $var++) //if value returned from database is 0, loop ends, if not, $var++
{
$value = $constant.$var; //gives me bbaa (the first possible sequence)
$num = mysql_num_rows(mysql_query("SELECT value FROM table WHERE value='$value")); //queries database to see if this already exists
}
echo $value;
so i want $value to give me bbae
I don't know if i'm close, but any help would be much appreciated. Thank you for taking time to reader this.
Ant