Duplication of Records

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chfarooq
    New Member
    • Aug 2006
    • 1

    Duplication of Records

    With this simple query, I am getting a duplicated record of sets. Can any body help me in this regard


    <?php
    $conn = oci_connect('IN KFISH_FAROOQ', 'farooq', '//localhost/XE');
    $stid = ociparse($conn, 'SELECT * FROM INKFISH_ADMIN.I NKFISH_USER');

    $results=ociexe cute($stid, OCI_DEFAULT);
    print '<table border="1">';
    while ($row = oci_fetch_array ($stid, OCI_RETURN_NULL S))
    {
    $item=null;
    foreach ($row as $item) {
    echo '<tr><td>'.($it em?htmlentities ($item):'&nbsp; ').'</td></tr>';
    }
    }
    print '</table>';
    oci_close($conn );
    ?>
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    Do you mean that you have double $items in your table row? The result of statement

    [PHP]echo '<tr><td>'.($it em?htmlentities ($item):'&nbsp; ').'</td></tr>';[/PHP]

    If so, the first item of the ternary probably is not seen as an expression by PHP.
    In that case you could do this

    [PHP]echo '<tr><td>'.(!em pty($item)?html entities($item) :'&nbsp;').'</td></tr>';[/PHP]

    Hope this works.

    Ronald :cool:

    Comment

    • somaskarthic
      New Member
      • Aug 2006
      • 60

      #3
      hi

      I think u have to find the solution in SQL query.
      while executing 'select * from table' , it fetches all the data .U have to try
      this using primary key value. Since, it is used to avoid duplicates.

      somas
      ---------




      Originally posted by chfarooq
      With this simple query, I am getting a duplicated record of sets. Can any body help me in this regard


      <?php
      $conn = oci_connect('IN KFISH_FAROOQ', 'farooq', '//localhost/XE');
      $stid = ociparse($conn, 'SELECT * FROM INKFISH_ADMIN.I NKFISH_USER');

      $results=ociexe cute($stid, OCI_DEFAULT);
      print '<table border="1">';
      while ($row = oci_fetch_array ($stid, OCI_RETURN_NULL S))
      {
      $item=null;
      foreach ($row as $item) {
      echo '<tr><td>'.($it em?htmlentities ($item):'&nbsp; ').'</td></tr>';
      }
      }
      print '</table>';
      oci_close($conn );
      ?>

      Comment

      • bevort
        New Member
        • Jul 2006
        • 53

        #4
        Testing the echo(.... command works in both the original way and the included test with !empty(). The last is not nessecary but can be used to make the command more readable.
        The ternary conditional operator structure uses the first expression to determen if the second or the third must be used. If a first string is not assign, so NULL, or "" (empty) does not matter. they will return False. If there is a single caracter or more the test will return True and use the second value

        So it must be in the database.
        I should check your table using a query tools and ask the same query directely to the database. If you have dubbles there they will show upp. Try diffeant sortings also

        Vincent

        Comment

        • epuck
          New Member
          • Nov 2007
          • 1

          #5
          You should add in "OCI_ASSOC" flag

          Code:
           while ($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS))
          This function was changed because of a php bug. http://bugs.php.net/bug.php?id=3748 7

          gl

          Comment

          Working...