The following is part of the scripts in my wepages.
Is there any problem using loop with mysql+php?
It can't do looping, the query statment only execute once, and then the error statment "Couldn't add client." is printed.
Is there any wrong?
<?
$connection = mysql_connect("localhost","database","password")
or die ("Couldn't connect to server.");
$db = mysql_select_db("database", $connection)
or die ("Couldn't select database.");
$fund_no=count($fund_id);
for($index=0; $index<$fund_no;$index++)
{
$sql= "insert into select_fund(user_id,client_id,fund_id) values('$user_id','$client_id','$fund_id[$index]')";
$result = mysql_query($sql,$connection) or die("Couldn't add client.");
}
........
?>
notes:the $fund_id was selected by user, and the $fund_id can be selected more than one and store in array.