cheechm Posted August 13, 2008 Share Posted August 13, 2008 Hi, I have this code: $item = split(', ', $row['items']); foreach ($item as $value) { $sqli = "SELECT name FROM hire WHERE id = " . $value . ""; $resulti = db_query($sqli) or die("MySQL ERROR: " . mysql_error()); while ($rowi = db_fetch_array($resulti)) { echo $rowi['name']; } } Lets say I get for $value: 2, 2, 3, 4 You can see there is two "2"s. How do I remove one of them? So the MySQL query only checks, 2, 3, 4? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/119556-solved-remove-entry/ Share on other sites More sharing options...
wildteen88 Posted August 13, 2008 Share Posted August 13, 2008 array_unique Quote Link to comment https://forums.phpfreaks.com/topic/119556-solved-remove-entry/#findComment-615940 Share on other sites More sharing options...
DarkWater Posted August 13, 2008 Share Posted August 13, 2008 Or: SELECT DISTINCT name FROM hire WHERE id = $value; You shouldn't have repeating data in the first place though. Quote Link to comment https://forums.phpfreaks.com/topic/119556-solved-remove-entry/#findComment-615944 Share on other sites More sharing options...
cheechm Posted August 13, 2008 Author Share Posted August 13, 2008 Or: SELECT DISTINCT name FROM hire WHERE id = $value; You shouldn't have repeating data in the first place though. Why not? I might need it. Thanks guys. Quote Link to comment https://forums.phpfreaks.com/topic/119556-solved-remove-entry/#findComment-615945 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.