Mr Chris Posted November 27, 2009 Share Posted November 27, 2009 Hi All, I have a query for getting some values for a column out of a mysql database. Basically if the value is 1 'Yes' is ticked and if the value is 0 'No' is ticked. Apart from making the values checked or not checked. Now this works fine: <?php $subsections = mysql_query("SELECT * FROM file WHERE websheet = 0"); while ($subsection = mysql_fetch_array($subsections)) { echo ' <span> '.$subsection['description'].'<br /> <label for="'.$subsection['description'].'"> <input type="radio" class="checkbox" name="subsection['.$int.']" value="1"'; if (in_array($subsection['section_id'] == 1)) { echo ' checked="checked"'; } echo ' /> Yes <input type="radio" class="checkbox" name="subsection['.$int.']" value="1"'; if (in_array($subsection['section_id'] == 0)) { echo ' checked="checked"'; } echo ' /> No </label></span> '; if ($ml10 == 4) { $ml10 = 1; } else { $ml10++; } $int++; } // end while subsectionRows echo '</fieldset></div>'; //} // end while sectionRows ?> Now the Only problem with this is these part if (in_array($subsection['section_id'] == 1)) { echo ' checked="checked"'; } echo ' /> Yes if (in_array($subsection['section_id'] == 0)) { echo ' checked="checked"'; } echo ' /> No Basically depending if it's a Yes or no I want the checkbox to be checked, but I get this error: Warning: Wrong parameter count for in_array() in /home/********/public_html/cms-testing/admin/options/edit.php on line 146 Can anyone kindly help? Thanks Link to comment https://forums.phpfreaks.com/topic/183105-wrong-parameter-count-for-in_array/ Share on other sites More sharing options...
trq Posted November 27, 2009 Share Posted November 27, 2009 You have only passed one argument to in_array, it expects two. Your code should be.... <input type="radio" class="checkbox" name="subsection['.$int.']" value="1"'; if (in_array(1, $subsection['section_id'] )) { echo ' checked="checked"'; } echo ' /> Yes Link to comment https://forums.phpfreaks.com/topic/183105-wrong-parameter-count-for-in_array/#findComment-966357 Share on other sites More sharing options...
trq Posted November 27, 2009 Share Posted November 27, 2009 Pfff.... scrap that. $subsection['section_id'] isn'tt even an array. <input type="radio" class="checkbox" name="subsection['.$int.']" value="1"'; if ($subsection['section_id'] ==1) { echo ' checked="checked"'; } echo ' /> Yes Link to comment https://forums.phpfreaks.com/topic/183105-wrong-parameter-count-for-in_array/#findComment-966358 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.