Implode means return a string from the elements of an array that means it converts an array into the srting.Explode split a string by string,it change a string into an array.
For example consider a simple driving form,
<form name="aform" method="post" action="conn.php" onsubmit="return validation();"> <table border="0px" cellpadding="10" cellspacing="0" id="tbl"> <tr><td align="center" colspan="2">Sample Driving Form</td></tr> <tr> <td>Vehicle</td> <td><input type="checkbox" name="vehicle[]" value="bus" />bus <input type="checkbox" name="vehicle[]" value="car" />car <input type="checkbox" name="vehicle[]" value="bike" />bike</td> </tr> <tr><td colspan="2" align="center"><input type="submit" name="submit" value="submit" /></td></tr> </table> </form>
Lets see the output
Implode the datas using database :
Connect the database :
<?php $conn=mysql_connect("127.0.0.1","root","") or die(mysql_error()); $select_db=mysql_select_db("arrayconcept_db",$conn) or die(mysql_error()); ?>
Insert into the database :
<?php if(isset($_POST['submit'])) { print_r($_POST); $vehicle=$_POST['vehicle'];
$r=implode(",",$vehicle);
$insert=mysql_query("insert into arrayconcept_tbl(vehicle) value ('$r')") or die(mysql_error()); } ?>
After implode into the databse the output will be
Informative article. Thanks for sharing this awesome article with us.
ReplyDeleteAngularJS training in chennai | AngularJS training in anna nagar | AngularJS training in omr | AngularJS training in porur | AngularJS training in tambaram | AngularJS training in velachery
how to find number rows where vehicle = bus
ReplyDeleteIn the wake of going over a modest bunch of the blog articles on your site, I really appreciate your procedure of composing a blog. I bookmarked it to my bookmark site page list and will return sooner rather than later. Kindly look at my site also and let me understand your opinion.
ReplyDeleteevrmag
also use it to promote your latest products and offers or inform people about what your business does. event marketing and sample introductions of guest speakers
ReplyDelete