Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Duplicate valueS?????

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Duplicate valueS?????

Postby acswilson » Sat Sep 06, 2003 2:44 am

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.
Code: Select all
 <?
   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";
                     }
                  }
               }
            
   }
?>
acswilson
New php-forum User
New php-forum User
 
Posts: 18
Joined: Thu Jul 17, 2003 7:42 am

Postby Redcircle » Sat Sep 06, 2003 10:41 am

You only need to post a question once..
User avatar
Redcircle
Moderator
Moderator
 
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA


Return to PHP coding => General

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.