Hallo! I have table with this structure: CREATE TABLE `product` ( `id` int(11) NOT NULL auto_increment, `name` text NOT NULL, PRIMARY KEY (`id`) ) ; INSERT INTO `product` (`id`, `name`) VALUES (1, 'car'), (2, 'car'), (3, 'motor'), (4, 'motor'); PHP: mysql_connect ("localhost", "user", "pass"); mysql_select_db ("catalog"); $select = "SELECT id, name FROM `product`"; $query = mysql_query ($select); echo "<table border=1>"; while ($row = mysql_fetch_array ($query)) { echo "<tr><td>" . "<b>" . $row['id']. "</b>" . "</td><td>" . $row['name'] . "</td></tr>"; } echo "</table>"; PHP: This output: 1--car 2--car 3--motor 3--motor How in while condition I can restrict duplicate data? I want retrieve: 1--car 2--motor Any suggestion? Thanks!
Thank you! Because I binding this output with another table, I want to using some PHP formatting in WHILE loop. Just eliminate duplicate row with PHP code ...
while ($row = mysql_fetch_array ($query)) { if ($sname !=$row['name']) { echo "<tr><td>" . "<b>" . $row['id']. "</b>" . "</td><td>" . $row['name'] . "</td></tr>"; } $sname !=$row['name']); } try with it , if it helps you