I have got a table in my MySql database:
pageid | text
-----------+----------
1 | test
-----------+----------
2 | example
-----------+----------
3 | another
-----------+----------
1 | example1
and this PHP code:
$query = "SELECT pageid FROM test";
$result = mysql_query($query);
while($row = mysql_fetch_array($result))
{
$id = $row['pageid'];
$id1 = array($id);
$id2 = array_unique($id1);
foreach ($id2 as $value)
{
echo $value . "<br>";
}
}
But it returns:
1
2
3
1
I would like to make the pageid
s unique. So I would like to echo out the number 1
, once. Like this:
1
2
3
So what am I doing wrong? How could I achieve what I want?
Thanks in advance...
[I know that this code doesn't make much sense, but this is just a demo for this question and I have a much more complicated code :) ]