blurredvision Posted September 6, 2008 Share Posted September 6, 2008 Currently, I'm pulling a column from a table in mysql based on whether a user is active or not. If a user is active, then it will return a value from a column. I'm wanting to check against each value in the array that is created, and if none of them match what I'm looking for, then I want to echo some text. Here's what I've written, but I do know that it's wrong where I'm trying the IF function. I'm posting this just to kind of show you what I'm trying to do, and hopefully you guys can show me what the correct syntax is to check against the entire array. I tried doing a WHILE and running through the array, but it obviously would echo the contents multiple times for however many keys were in the array. EDIT: The $matchups array is one that is created before getting to this block of code....this block of code is in a while loop, just to give you some perspective. $query = "SELECT team,gamertag,active_status FROM user"; $queryresult = mysqli_query($dbc, $query) OR die(); $hpu = mysqli_fetch_array($queryresult); if ($matchups['active_status'] == 1) { if ($matchups['opponent'] != $hpu['team']) { echo '<span class="enterstats">'; echo '- ' . $matchups['team'] . ' (' . $matchups['gamertag'] . ') vs ' . $matchups['opponent']; echo '</span><br />'; } } Thanks for any advice! Link to comment https://forums.phpfreaks.com/topic/123027-how-to-check-for-a-value-in-an-array/ Share on other sites More sharing options...
DarkWater Posted September 6, 2008 Share Posted September 6, 2008 Where are you getting $matchups from? You might be able to just do a join. Link to comment https://forums.phpfreaks.com/topic/123027-how-to-check-for-a-value-in-an-array/#findComment-635252 Share on other sites More sharing options...
blurredvision Posted September 6, 2008 Author Share Posted September 6, 2008 Where are you getting $matchups from? You might be able to just do a join. Just added that to the OP. Link to comment https://forums.phpfreaks.com/topic/123027-how-to-check-for-a-value-in-an-array/#findComment-635253 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.