Found the problem - Craig
On Mar 10, 2005, at 5:47 PM, Craig Hoffman wrote:
Hello,
I could use some assistance here. I'll try and explain this the best
I can. I'm trying to get this query to work where it pulls up all the
rows that are associated with a common id . For example let say you
have data that you want to group together. For example:
Group 1 would look like this:
Title 1
Abstract for title 1
- articles that belong to title 1
- articles that belong to title 1
Then group two:
Title 2
Abstract for title 2
- articles that belong to title 2
- articles that belong to title 2
and so forth
Basically my script is working, it queries the correct results, but
it only pulls up one set of results (title 1), instead of ALL results.
I am including the code below, perhaps someone could take a look at
it? I hope this makes sense? :)
- Craig
<?php
require ("include/db.php");
$query = "SELECT * FROM clients, articles WHERE clients.id =
articles.id GROUP BY co_name ORDER BY date_uploaded";
$result = mysql_query($query, $db) or die(mysql_error());
echo("<h3>Client List</h3>");
while ($row = mysql_fetch_array($result)) {
$co_name = $row['co_name'];
$co_logo = $row['co_logo'];
$co_text = $row['co_text'];
$corp_name = array("$co_name");
print_r ($corp_name);
foreach ($corp_name as $corp1_name) {
$rc = "\r";
if ($co_logo = $co_logo) {
echo ("<img src='./image/client_graphics/$co_logo' alt='$co_logo'
width='150' height='69' class='co_name_img'>");
}
echo("<p>");
echo ereg_replace($rc, '<br />', trim(stripslashes("<div
class='res_header'>$corp1_name</div>")));
echo ereg_replace($rc, '<br />', trim(stripslashes("$co_text")));
$query = "SELECT articles.*, clients.id FROM articles, clients WHERE
clients.id = articles.id AND co_name = '$corp1_name' GROUP BY
article_name ORDER BY date_uploaded";
//echo $query;
$result = mysql_query($query, $db) or die(mysql_error());
echo("<ul class='client_list'>");
while ($row = mysql_fetch_array($result)) {
$article_name = $row['article_name'];
echo("<li>$article_name</li>");
}
echo("</ul>");
echo("</p>");
}
}
?>
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php