php - displaying value of dynamic checkbox in next page . and inserting such value -
i've created dynamic checkbox, failed display value on page. work have done following:
index.php
<form method="post" action="print.php"> <?php $host="localhost"; $username="root"; $password=""; $database="checkbox"; mysql_connect($host,$username,$password); mysql_select_db("$database"); //create query $sql = "select test, rate lab"; $result = mysql_query($sql) or die(mysql_error()); while($row = mysql_fetch_assoc($result)) { echo <<<eol <input type="checkbox" name="name[]"value="$row['test']}/{$row['rate']}"/> {$row['test']}-{$row['rate']}<br /> eol; } ?> <br> <input type="submit" name="submit" value="add" /> </form>
i trying display value on secon page called print.php:
<?php print $_post['name']; ?>
see what's happening in code:- naming check box in array. when submission in php receive array name :- name[] $_post['name'] return array in php. when use print method can print variable value . can't print array or object . if use print/echo method print array/object print type. print array can use print_r() method or can use var_dump() check in variable. can access array favourite way loop. more print-r , var_dump please follow manual link [php.net manual][1] http://www.php.net/manual/en/function.var-dump.php
Comments
Post a Comment