SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2010
    Posts
    93
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    I want to prevent the display of repeated row in database

    PHP Code:
    <?php
    require_once('upper.php');
    require_once(
    'database.php');
    require_once(
    'LoginStatement.php');
    $LoginId=$_COOKIE['LoginIdCookie'];
    $query="select * from activity_participation where LoginId='$LoginId'";
    $result=mysqli_query($dbc,$query) or die ('Not Connected');
    //echo "<div class='search_output_data'>
    echo "<table border='0' cellspacing='0' cellpadding='0'>";
    while(
    $row=mysqli_fetch_array($result))
    {
    echo 
    "<tr><th align='left' valign='top'>Activity Title</th>
    <th align='left' valign='top'>Date of Participation</th>
    </tr>
    <tr><td colspan='4' align='left' valign='top'><table align='left' border='0' cellspacing='0' cellpadding='0'><tr><td align='left' valign='top'>"
    .$row['Title']."</td> <td align='left' valign='top'>".$row['Date']."</td> </tr></table>
    </td></tr>"
    ;
    }
    echo 
    "</table>";
    //echo "</div>";
    require_once('lower.php');
    ?>
    In table activity_participation many rows have same values. I want to display only different rows to user not to display same rows again and again.
    Or Anybody have idea to prevent the row duplication in database....
    Help me plz.........
    thx in advance.............

  2. #2
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    You could you the DISTINCT keyword in your query, once you figure out whether you need distinct titles and/or dates.
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  3. #3
    SitePoint Enthusiast
    Join Date
    Nov 2010
    Posts
    93
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    in both titles and dates.....
    Please tell me the exeact query......

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,263
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by ankit.pandeyc012 View Post
    in both titles and dates.....
    Please tell me the exeact query......
    please first do a SHOW CREATE TABLE for your table

    then show a few rows of sample data

    then show the result that you want to display for the sample rows you gave
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •