php - insert checkbox values into database within a separate column of the query separated by commas -
i need problem i've been trying solve while (i'm new in php). have form several checkboxes values pulled specific table of database. managed display them in form, cannot insert values table connected specific page since there ony 1 column.i want enter selected values of checkbox single column separated commas.
here's code:
url <br><?php $query = "select url webmeasurements"; $result = mysql_query($query); while($row = mysql_fetch_row($result)) { $url = $row[0]; echo "<input type=\"checkbox\" name=\"url\" value=\"$row[0]\" />$row[0]<br />"; $checkbox_values = implode(';', $_post['url']); } ?> <input type="submit" name="submit" value="submit"> </form> <?php if(isset($_post['url'])) { echo $url; foreach ($_post['url'] $statename) { $url=implode(',',$statename) } } $q="insert table (url) values ($url)"; ?>
you should give each checkbox different name, not name="url" all, , check if(isset($_post['checkbox_name'])).
Comments
Post a Comment