Jump to content

I want to prevent the display of repeated row in database


ankit.pandeyc012

Recommended Posts

<?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.............

Link to comment
Share on other sites

You can use group by column_name to prevent that. Only the first row matching column_name will be returned.

 

For example, assume you have a table containing the following data:

 

col1 | col2

-----------

1    | a

1    | b

1    | c

2    | d

2    | e

2    | f

 

Using a group by on col1 would return:

 

col1 | col2

-----------

1    | a

2    | d

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.