Thursday, 15 May 2014

How to add check box value in array if it already coming from DB in php -



How to add check box value in array if it already coming from DB in php -

i have code displays items in check boxes items existing in db , values have given in db need map in page. how force array? code follow:

echo print_chkbx("select * product_master", database_connect($dbname));

and function is

function print_chkbx($query, $link){ $queried = mysql_query($query, $link); while ($result = mysql_fetch_array($queried)) { $menu .= ' <input name="check" type="checkbox" value="'. $result['product_id'] .'" />' . $result['product_name']; } homecoming $menu; }

this create products array in form.

put [] characters after input name signify inputs name separate entries in array.

$menu .= ' <input name="check" name="products[]" type="checkbox" value="'. $result['product_id'] .'" />' . $result['product_name'];

then upon submit served array:

<?php $products = $_request['products']; // used request unsure of (get||post) echo '<pre>',print_r($products),'</pre>';

php

No comments:

Post a Comment