OB82 Posted October 21, 2010 Share Posted October 21, 2010 Dear all, I am new in this forum. This is my code $query = " SELECT webdb.id, webdb.writer, writer.picLoc, webdb.title FROM webdb, writer WHERE webdb.writer=writer.name and category = 'Researchworks' and language = 'Farsi' ORDER BY writer DESC"; $resultaat = mysql_query($query, $LinkID); $column_count = mysql_num_fields($resultaat) or die (mysql_error()."<br>Couldn't execute query: $SQLquery"); $counter=1; echo "<table border=\"0\" width=\"700\" border color=white><tr>"; while ($row = mysql_fetch_row($resultaat)) { if ($author !== $row[1]) { $author = $row[1]; echo "<td align=right width=220 valign=top style=\"margin: 5px; float: right border-bottom-color:#000; border-left-color:#000;\">"; echo "<img width=\"50\" height=\"80\" src=\"admin/writers/$row[2]\" border =\"0\"><br>".$row[1]."<br>"; echo "<a href=\"poems.php?writer=$row[1]\">".$row[3]."</a><br>"; echo "</td>"; if($counter%3==0) { echo"</tr><tr>"; } $counter++; } } echo"</tr></table>"; i have authors with different articles on a certain topic. What i want is, displaying the name of the author only once and all his titles under his name. I also want a dynamic table where i display three authors in each row and soon as there a fourth author a new row must start. My problem now is is the title is also being filtered and i can only display one title. Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/216508-displaying-results-in-groups-please-help/ Share on other sites More sharing options...
OB82 Posted October 22, 2010 Author Share Posted October 22, 2010 Guys i NEED HELP!! Quote Link to comment https://forums.phpfreaks.com/topic/216508-displaying-results-in-groups-please-help/#findComment-1125123 Share on other sites More sharing options...
turkman Posted October 22, 2010 Share Posted October 22, 2010 SELECT webdb.id, webdb.writer, writer.picLoc, webdb.title FROM webdb, writer WHERE webdb.writer=writer.name and category = 'Researchworks' and language = 'Farsi' GROUP BY writer.name ORDER BY writer DESC"; Quote Link to comment https://forums.phpfreaks.com/topic/216508-displaying-results-in-groups-please-help/#findComment-1125146 Share on other sites More sharing options...
OB82 Posted October 22, 2010 Author Share Posted October 22, 2010 HI Turkman Thanks for you replay. The problem still remains. With this query that you have written, i can only display one title. I want all of their titles from a certain category to be displayed under their names. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/216508-displaying-results-in-groups-please-help/#findComment-1125163 Share on other sites More sharing options...
litebearer Posted October 22, 2010 Share Posted October 22, 2010 perhaps a rough idea (you will need to modify for your particular names & values)... $query = "SELECT * FROM tablename ORDER BY author_name"; $result = mysql_query($query); while($row=mysql_fetch_array($result)) { $author_name = $row['author_name']; echo $author_name "<br>"; $query2 = "SELECT * FROM tablename WHERE author_name = '$author_name'"; $result2 = mysql_query($result2); while($row2=mysql_fetch_array($result2)) { echo " " . $row2['title'] . "<br>"; } echo "<hr>"; } Quote Link to comment https://forums.phpfreaks.com/topic/216508-displaying-results-in-groups-please-help/#findComment-1125177 Share on other sites More sharing options...
OB82 Posted October 22, 2010 Author Share Posted October 22, 2010 Hi litebearer, Appreciate it man. It works fine... Quote Link to comment https://forums.phpfreaks.com/topic/216508-displaying-results-in-groups-please-help/#findComment-1125191 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.