jacko_162 Posted April 11, 2010 Share Posted April 11, 2010 i have the following if statement which works perfect; <?php $val1 = '379'; //----- CHANGE LOW VALUE $val2 = '391'; //----- CHANGE HIGH VALUE $val3 = '$test10'; //----- CHANGE TEST NUMBER $label = 'Potassium: '; //----- CHANGE TEST LABEL if (in_array('test10',$arr)){ //----- CHANGE TEST NUMBER echo '<tr>'; echo "<td width='40%' align='right'><em><strong>$label</strong></em></td>"; echo "<td width='15%'>$test10 ppm</td>"; //----- CHANGE TEST NUMBER if (($test10 > $val1) && ($test10 < $val2)) { echo '<td width="15%"><img src="img/icons/beaker_green.png" /></td>';} else { echo '<td width="6%"><img src="img/icons/beaker_red.png" /></td>';} echo '</tr>'; }else{ echo '';} ?> what i wanted to do next was not only check if 'test10' was in the array but also that $active10 had a '1' value in the database. so i tried the following; if (in_array('test10',$arr) && ($active10 = '1')){ but even if the $active10 variable had a '0' in database it still shows? i have assigend $active10 variable in the top of the php page like follows; <?php if ($ID) { $sql = "SELECT * FROM $table2 WHERE ID=$ID AND member_id=$_SESSION[sESS_MEMBER_ID]"; $result = mysql_query($sql); $myrow = mysql_fetch_array($result); $ID = $myrow["id"]; $member_id = $myrow["member_id"]; $test10 = $myrow["test10"]; $active10 = $myrow["active10"]; { $result2=mysql_query("SELECT * FROM $table3 WHERE member_id=$_SESSION[sESS_MEMBER_ID]"); $row2 = mysql_fetch_array($result2); $arr = array(); $arr = explode(';',$row2['settings']); ?> can anyone help me word it rightly please? Link to comment https://forums.phpfreaks.com/topic/198215-checking-if-statement/ Share on other sites More sharing options...
Chris92 Posted April 11, 2010 Share Posted April 11, 2010 What type is active 10? If it's an int or boolean, it won't read as a string, you'll need to use $active10 == 1 rather than $active10 == '1' Link to comment https://forums.phpfreaks.com/topic/198215-checking-if-statement/#findComment-1039996 Share on other sites More sharing options...
jacko_162 Posted April 11, 2010 Author Share Posted April 11, 2010 that did the trick thx Link to comment https://forums.phpfreaks.com/topic/198215-checking-if-statement/#findComment-1040002 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.