Jump to content

Displaying results in Groups: please help


OB82

Recommended Posts

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

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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>";
}

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.