Duplicate records

  • jordonshaw
  • Student
  • Student
  • User avatar
  • Posts: 96
  • Loc: Tennessee

Post 3+ Months Ago

Is it possible with PHP that when you submit a form and a record that matches it exactly is already in the Database, it just drops the new data and keeps the old, so that no duplicates will ever be there? If so, how?

Thanks,
Jordon
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • jordonshaw
  • Student
  • Student
  • User avatar
  • Posts: 96
  • Loc: Tennessee

Post 3+ Months Ago

Just wanted to explain this a little more. See my screen shot below. I have 5 containers to track the work flow. It is possible for 1 class to be in two different containers; however, I want to only display it once, if its moved to the same container. As you can see in the screen shot, its showing up twice. Currently I'm just running a while loop to pull the classes and what container they are in, is there anyway possible to change my query show that it only shows the class in the container once, if its moved to the same container?

Image

Thanks for your help!

Jordon
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8388
  • Loc: USA

Post 3+ Months Ago

You could count the number or rows there are in the database using the course name as a search query, and if there is either bring an error or have it go silently.
  • jordonshaw
  • Student
  • Student
  • User avatar
  • Posts: 96
  • Loc: Tennessee

Post 3+ Months Ago

Alright, so here is my current code that is generating those courses in the first container, cont_id = 1. So, what would I need to do to say, if the count > 1, then don't display it, or maybe change cont_id to 0, so it won't display in any container.

Code: [ Select ]
    <select name="sme" style='width:125px;' multiple size="9">
             <?php
            $sme = mssql_query("SELECT * from SNP_cont
            INNER JOIN SNP_crs ON SNP_cont.crs_id = SNP_crs.crs_id
                    WHERE (cont_id = 1)", $connection);
            if (!$sme) {
            die("Database query failed: " . mssql_error());
            }         
            while ($sme_sel = mssql_fetch_array($sme)) {     
            echo "<option value=\"{$sme_sel['sel_id']}\">{$sme_sel['crs_author']}</option>";
            }
        ?>
     </select>
  1.     <select name="sme" style='width:125px;' multiple size="9">
  2.              <?php
  3.             $sme = mssql_query("SELECT * from SNP_cont
  4.             INNER JOIN SNP_crs ON SNP_cont.crs_id = SNP_crs.crs_id
  5.                     WHERE (cont_id = 1)", $connection);
  6.             if (!$sme) {
  7.             die("Database query failed: " . mssql_error());
  8.             }         
  9.             while ($sme_sel = mssql_fetch_array($sme)) {     
  10.             echo "<option value=\"{$sme_sel['sel_id']}\">{$sme_sel['crs_author']}</option>";
  11.             }
  12.         ?>
  13.      </select>
  • jordonshaw
  • Student
  • Student
  • User avatar
  • Posts: 96
  • Loc: Tennessee

Post 3+ Months Ago

I figured this out. I used a if statement and a mssql_num_rows function and basically wrote a script that said if the number of rows is < than 1, then delete the entry, if not, then post.

Post Information

  • Total Posts in this topic: 5 posts
  • Users browsing this forum: No registered users and 57 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.