Problem in Inserting Records

  • 15 years ago

    Hi expertzz!!


    1) I m new in PHP and Mysql. I m facing sum problems. i have make simple form in which i m inserting row in my mysql database. but the problems is, it's also storing dublicate rows, means same row are inserting in databse table 2 to 3 times while refreshing page. Now i want to check dublicate rows should not enter in database!!



    2) I have make combo box which is dynamically bounded and refreshing it while selecting value(means Country combo displays related States and State displays related City) but when combo box refreshed values entered by User in above Textboxes,than values are not there means it refreshing whole page due to which values are not stored!! what will i do to Restore value while refreshing combo box. My code is



       <?php
                  if(!empty($country) and $country==229)
             {
     $q="select distinct us.StateCode from uscitystatezip us,country ct where us.countryid=ct.countryid and ct.countrystrlongname='united states of america' order by StateCode";
     $ret=mysql
    query($q, $con)or die(mysqlerror());
     echo "<select name=state class=font10 onChange='javascript:document.form3.submit()'>"; //Refreshing here
     while($line1=mysql
    fetch_row($ret))
     {
     echo "$line1[0]";
     //foreach($line as $value)
     //{
     //print "<option value='$value'>$value</option>";
     print "<option value='$line1[0]'" ;
     if (!empty($state))
     {
     if ($line1[0] == $state)
     {
       print "selected";
     }
      }


     print">$line1[0]</option>";
      }
     // }
     print "</select>";
     }
     else
     {
     echo "--Select State--";
     }


     ?>





    Waiting 4 ur reply!


    Thnxx


Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“There are only two kinds of languages: the ones people complain about and the ones nobody uses” - Bjarne Stroustrup