JSHINER Posted December 4, 2008 Share Posted December 4, 2008 <?php $array = "SELECT id FROM table_b"; $array = mysql_query($array) or die("Error: " . mysql_error()); $array = mysql_fetch_array($array); while($row = mysql_fetch_array($result)){ } ?> The $array returns results such as 01, 02, 03 etc and the $row has table.id with numbers that MAY match 01,02,03 etc. How can I get an if statement in the while loop that only displays something if the table.id DOES NOT match the table_b.id result in the $array. Link to comment https://forums.phpfreaks.com/topic/135520-solved-while-array-question/ Share on other sites More sharing options...
Adam Posted December 4, 2008 Share Posted December 4, 2008 The solution would be in your SQL: SELECT table_b.id FROM table_b, table WHERE table_b.id != table.id I've not tested that but looks kinda right! I'd suggest tidying up your code, what you supplied barely makes sense. Also I'd avoid using predefined names for tables such as "table" and "$array" for arrays... Try to avoid reusing your variables like that as well, just confusing! Adam Link to comment https://forums.phpfreaks.com/topic/135520-solved-while-array-question/#findComment-705989 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.