Re: php newbie having trouble going to list page

From: Date: Sun, 09 Apr 2006 02:59:09 +0000
Subject: Re: php newbie having trouble going to list page
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-233601@lists.php.net to get a copy of this message
David Doonan wrote: > I'm having trouble getting the correct results on a list page. > > The first query is pulling the name of active authors from the d/b and > linking to a list page that is supposed to return essay titles by the > requested author. The list page however is displaying essay titles by > all authors. > > No doubt something is wrong with the where clause in the List page > query. I've tried countless variations on the syntax for Author.ID = > Author.ID without success. > > Sorry for so basic a question. > > --------------------- > author page query = > > $query_GetAuthors = "SELECT Distinct Author.Autholr_Name, Author.ID, > Writings.Writings_Author FROM Author, Writings > WHERE Author.Autholr_Name = Writings.Writings_Author and > Author.ID = Author.ID"; > ... > -------------------- > author page link = > <a href="author.php?ID=<?php echo $row_GetAuthors['ID']; > ?>"><?php echo > $row_GetAuthors['Autholr_Name']; ?></a> > > > --------------------- > List page query = > > $query_GetAuthorList = "SELECT Writings.Writings_Author, > Writings.Writings_Title, DATE_FORMAT(Writings_Date, '%M %D, %Y') as > Writings_Date, Writings.Writings_Text, Writings.ID, > Author.Autholr_Name, Author.ID FROM Writings, Author > WHERE Writings.ID = Writings.ID AND > Author.Autholr_Name = Writings.Writings_Author AND > Author.ID = Author.ID > ORDER BY Writings.Writings_Date desc"; > ... Nowhere in your query are you actually specifying which author you want to get results for. You need to use the variable passed to the page as part of the query. Try adding something like the following to your where block. "Author.ID = ".mysql_real_escape_string($_GET['ID']) David

« previous php.general (#233601) next »