Is it possible to insert multiple values from text into multiple columns seprated by comma.for example i have a table products in which columns are product_name,product_description,lisencekey1, lisencekey2 ,..................and with entering the multiple lisencekeys(only) seprated by comma should be inserted in this fields.

Recommended Answers

All 2 Replies

Try this

$arrays = explode(",",$licencekeys);
foreach($arrays as $array) {
echo "Licence Key 1 : $array 
      Licence Key 2 : $array";
}
Member Avatar for diafol

I'm not sure what you're trying to do. Insert license keys into a DB table from a comma delimited string?

$licencekeys="t,d,r";
if($licencekeys !=""){
	$bits = explode(",",$licencekeys);
	for ($x=1;$x<count($bits);$x++){
	  $str[] = "`lisencekey$x` = '{$bits[$x-1]}'";
	}
	$sqlpart = implode(",",$str);
}else{
		$sqlpart = "";
}
//check with: echo $sqlpart;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.