Showing numbers from a database that doesn't excist
Posted: Sun Jul 23, 2006 5:05 am
Hey,
I'm doing a script that looks in a mysql database and looks for numbers that doesn't excist in it and writes those numbers out.
A little example, I've got these numbers in my database and i want to show the two lowest numbers that doesn't excists in the database.
1
2
3
4
6
7
9
That's what i have in my database. Then i want it to write out the numbers 5 and 8 cause they don't excist in the database.
The code i got atm is:
But that won't work.
Thanks
I'm doing a script that looks in a mysql database and looks for numbers that doesn't excist in it and writes those numbers out.
A little example, I've got these numbers in my database and i want to show the two lowest numbers that doesn't excists in the database.
1
2
3
4
6
7
9
That's what i have in my database. Then i want it to write out the numbers 5 and 8 cause they don't excist in the database.
The code i got atm is:
Code: Select all
<?php
$datum = date("d/m/y");
$stora = array("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "Å", "Ä", "Ö");
$sma = array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "å", "ä", "ö");
$smaword2 = str_replace($stora, $sma, $word[2]);
$sql = "SELECT bud FROM $MYSQL_TABLE WHERE item='$smaword2'";
$res = mysql_query($sql);
$c = 0;
$min = array();
$num = mysql_num_rows($res);
for ($i = 1; $i < $num; $i++)
{
$row = mysql_fetch_assoc($res);
if ($i != $row['bud'])
{
$c++;
$min[] = $i;
}
if ($c == 2) {
$tal = explode(" ", $c);
echo "De talen som inte har fått något bud är: ". $tal['1'];
echo " och ". $tal['2'];
break;
} else {
echo "ERROR";
}
}
?>Thanks