Originally posted by Sxooter
the problem is that PHP can't be sure just how to interpret the $andel[$i] part of your query. Just put it outside the quotes so it isn't ambiguous like so:
$result = mysql_query("SELECT Portkod FROM Uppgifter WHERE Andel='".$andel[$i]."'");
[/B]
I tried this notation but the query still doesn't work.
I want to query the second db on the same 'Andel' numbers that are found in the first search AND in the same order that are given by this search.
First query statement:
$svar = mysql_query("SELECT Andel, substring_index(Namn,' ',1) AS surname FROM Uppgifter WHERE Andel>=24 AND Andel <=48 GROUP BY Andel, surname ORDER BY surname ");
In the first search I'm getting duplicates of 'Andel' and it is important that I get rid of those before I do the second search. That's why I thought making it an array and using array_unique().
I also tried using SELECT DISTINCT Andel, surname... and simply do the second query within the while loop of the first query. But i'm still getting duplicates of $andel totally messing up the 'Portkod' query.
So I'm back at trying to do a query using an array in the WHERE statement