php - How can I run a function with an array of checkbox values passed as an argument? -
so i'm wanting run function every time user clicks btnchangecat
button...im having trouble , i'm not sure how work!
im trying run showcategory($_post['chkcat'], 1)[0];
and pass array of checked checkboxes when user clicks btnchangecat
button. im not sure why isn't working??
i've literally searched everywhere working solution can't find 1 work when passing values function!
$showvideos = showcategory($categories, 1)[0]; $rowlength = showcategory($categories, 1)[3]; $likes = showcategory($categories, 1)[1]; $dislikes = showcategory($categories, 1)[2]; ?> <main> <div class='controller-wrap'> <div class='content-wrap'> <h3>category: </h3>hp <form action='most-liked.php' method='post'> <?php $allcategories = ["all", "sport", "automotive", "comedy", "misc", "surfing"]; $htmloutput = ""; $i=0; for($i;$i<sizeof($allcategories);$i++) { if($allcategories[$i] == "surfing"){ $htmloutput .= "<input selected='selected' type='checkbox' name='chkcat[]' value='".$allcategories[$i]."'/>"; } else{ $htmloutput .= "<input type='checkbox' name='chkcat[]' value='".$allcategories[$i]."'/>"; } } echo $htmloutput; ?> </form> <br /> if(isset($_post['chkcat'])){ if(is_array($_post['chkcat'])) { foreach($_post['chkcat'] $value){ echo $value; } }else{ $value = $_post['chkcat']; echo $value; } // showcategory($_post['chkcat'], 1)[0]; } isset($_post['btnchangecat'])){ // //how can run function array of checkboxes?? showcategory($_post['chkcat'], 1)[0]; } ?> <input type='submit' value='change categories' class='btnlike btnlike' name='btnchangecat'/> </div> </main>
Comments
Post a Comment