Double Insert Values ?
Why the code below will insert more than one time for each value???
because it is a check box so i need to use array to make it insert more
than one value into the table but not more times for each value.
<?
if ($society == NULL)
{
echo"Please Try Again!!!<br><br><br>";
echo"NO Society<br><br><br>";
echo "Click <a href=\"society1.php\">here</a> to try again !!<br>";
exit;
}
else
{
$mysql_access = mysql_connect("localhost", "root", "");
mysql_select_db("mw");
$result = mysql_query("select * from society2");
$number_of_rows = mysql_num_rows($result);
$i=0;
$check=0;
while ($number_of_rows != 0)
{
$row = mysql_fetch_row($result);
$number_of_rows--;
if ($value==$row[0] && $username1==$row[1])
{
echo "<br>Invalid society <BR>Currently the $value has been checked!!<br>";
echo "<BR>Click <a href=\"society1.php\">here</a> to try again !!<br>";
exit;
}
else
{
foreach ($society as $key => $value)
{
$query = "INSERT INTO society2 values(\"$value\",\"$username1\")";
mysql_query($query, $mysql_access);
echo "<br>\n<font face=\"Arial Narrow\"><font size=\"3\">Society :$value</font><br>\n";
echo "<font face=\"Arial Narrow\"><font size=\"3\">Username :$username1</font><br>\n";
}
}
}
}
?>