Re: printing a one-to-many relationship

From: Date: Wed, 25 Apr 2007 20:22:29 +0000
Subject: Re: printing a one-to-many relationship
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-253744@lists.php.net to get a copy of this message
give this a shot <html> <head><title>items and notes</title></head> <body> <?php $user="feeds"; $host="localhost"; $password="password"; $database = "feeds"; $connection = mysql_connect($host,$user,$password) or die ("couldn't connect to server"); $db = mysql_select_db($database,$connection) or die ("Couldn't select database"); $query = "SELECT * FROM contacts, px_items WHERE contacts.id=px_items.id ORDER BY px_items.id DESC"; $result = mysql_query($query) or die ("Couldn't execute query."); $title = ''; while ($row = mysql_fetch_array($result)) { if ( $title != $row['title'] ) { $title = $row['title']; echo "<h2>{$title}</h2>"; } echo "&nbsp;&nbsp;{$id} - {$content} - {$timestamp} - {$notes} - ". "<a href=\"{$link}\">{$link}</a><br>"; }//while ?> </body> </html> This should do the trick -- Enjoy, Jim Lucas Different eyes see different things. Different hearts beat on different strings. But there are times for you and me when all such things agree. - Rush

« previous php.general (#253744) next »