insert array problem

gesf

Active member
foreach is your answer! Read this manual page ...

Give this code a try so you have an idea on how it works.
Example 1:
Code:
<?php

$array = array("one","Two","Three","Four","Whatever");
foreach($array as $v) { print $v . "<br />"; }

?>
Example 2:
Code:
<?php

$array = array("value 1","value 2","value 3","value 4","value whatever");
$string = '';
foreach($array as $v) { $string .= "'" . $v . "',"; }
print "INSERT INTO table contents VALUES(" . substr($string, 0, -1) . ");";

?>

Hope it helps!
 
Back
Top