PHP MYSQLI-how to view the items from the table once -


i want display items database once using description attribute of files. example uploaded 3 files, automatically have same information except primary key.

if($type=="title"){ $key = $_post['search_key'];     if($key!=null){          $result = mysqli_query($con,"select distinct description  __scannedfiles title='$key' ,  deptname='$dept_name'")  or die(mysqli_error());     $count =mysqli_num_rows($result);     if($count==0){        echo '<script type="text/javascript"> window.onload = function(){alert("file not found!")} </script>';     } else if($count>0) {         echo'<div class="searched_items_pane">        <table class="table" width="100%" style="table-layout:fixed">          <col width="20%">         <tr>         <td> </td>         <th>  title </th>          <th> type </th>         <th> date </th>         <th>  description </th>         </tr>';     while($row = mysqli_fetch_array($result)){       echo'<tr>         <td><a href="items.php?     desc='.urlencode($row[7]).'"onclick="mm_openbrwindow(\'items.php?desc='.urlencode($row[7]).'\',\'google\',\'width=650,height=500\'); return false;">         <img src="folder-blank-icon.png"></a></td>              <td> '.$row[1].' </td>         <td> '.$row[5].' </td>         <td> '.$row[6].' </td>         <td> '.$row[7].' </td>          </tr>';     }     if($count>0){       echo'</table>        </div>';     } }                                }   } mysqli_close($con);       } 

result:

     karla   memo    2012-12-31  2131      karla   policy  2013-12-31  121212      karla   memo    2013-12-31  qweqw      karla   memo    2013-12-31  qweqw 

here desired result:

     karla   memo    2012-12-31  2131      karla   policy  2013-12-31  121212      karla   memo    2013-12-31  qweqw 

it's hard without desired output , table __scannedfiles structure can try using distinct

$result = mysqli_query($con,"select distinct * __scannedfiles title='$key' ,  deptname='$dept_name'"); 

sqlfiddle


Comments