Quantcast
Channel: PHP array from checkbox values returns only Array instead of values - Stack Overflow
Viewing all articles
Browse latest Browse all 2

PHP array from checkbox values returns only Array instead of values

$
0
0

According to suggestion here to use $_POST method to declare array from checkbox values I made it. But it isn't working.

In mysql table below, it stores only text that says Array. It doesn't store any of the values checked.

Even if I put echo like in the code below, it prints out "Array".

HTML PAGE WITH QUESTIONNAIRE

<input type="checkbox" name="cb1[]" value="Mike"><input type="checkbox" name="cb1[]" value="Irena"><input type="checkbox" name="cb1[]" value="Sonya"><input type="checkbox" name="cb2[]" value="Samsung"><input type="checkbox" name="cb2[]" value="Apple">

PHP SCRIPT

for($i=1;$i<101;$i++) {    if(isset($_POST['cb'.$i])) {        $row[$i] = $_POST['cb'.$i];    }}echo $row[1]; //it gives Array insted of values selected in the cb1<?php$db =& JFactory::getDBO(); $query = "INSERT INTO storeresults(V1, V2) VALUES ('$row[1]','$row[2]')"; $db->setQuery($query); $db->query();?>

Viewing all articles
Browse latest Browse all 2

Trending Articles