larry_boy_44 Posted April 28, 2007 Share Posted April 28, 2007 I know the MySQL query is working properly, but for some reason it won't grab more than 1 row worth of results... you guys have any idea why? code: $ArticleQuery = "Select Article.`Date`, Article.`Title`, Article.`Description`, Author.`FirstName`, Author.`LastName` From Article Article, Author Author, Author_Article_Intersect Author_Article_Intersect Where ( Author_Article_Intersect.AuthorID = ' $AuthorID' And Author_Article_Intersect.ArticleID = Article.ArticleID )"; $ArticleResult = mysql_query($ArticleQuery) or die ("Couldn't execute Query 2."); $ArticleArray = mysql_fetch_array($ArticleResult) or die ("Couldn't fetch result 2."); when I try to use the query, I get 1 row-worth of results (1 row from each database) and that's it... Link to comment https://forums.phpfreaks.com/topic/49050-problem-grabbing-more-than-1-row-of-data-from-mysql-database-using-php/ Share on other sites More sharing options...
heckenschutze Posted April 28, 2007 Share Posted April 28, 2007 Why wouldn't you? Your only asking for one row, mysql_fetch_array -> "Fetch a result row as an associative array, a numeric array, or both" read http://php.net/mysql_fetch_array Link to comment https://forums.phpfreaks.com/topic/49050-problem-grabbing-more-than-1-row-of-data-from-mysql-database-using-php/#findComment-240325 Share on other sites More sharing options...
larry_boy_44 Posted April 28, 2007 Author Share Posted April 28, 2007 Why wouldn't you? Your only asking for one row, mysql_fetch_array -> "Fetch a result row as an associative array, a numeric array, or both" read http://php.net/mysql_fetch_array did I mention I'm not very good at this? lol Link to comment https://forums.phpfreaks.com/topic/49050-problem-grabbing-more-than-1-row-of-data-from-mysql-database-using-php/#findComment-240328 Share on other sites More sharing options...
larry_boy_44 Posted April 28, 2007 Author Share Posted April 28, 2007 how do I fetch columns... or better yet multiple rows? Link to comment https://forums.phpfreaks.com/topic/49050-problem-grabbing-more-than-1-row-of-data-from-mysql-database-using-php/#findComment-240329 Share on other sites More sharing options...
heckenschutze Posted April 28, 2007 Share Posted April 28, 2007 while ($row = mysql_fetch_array($ArticleResult, MYSQL_ASSOC)) { // $row contains the nth row. echo "<pre>"; print_r($row); echo "</pre>"; } Link to comment https://forums.phpfreaks.com/topic/49050-problem-grabbing-more-than-1-row-of-data-from-mysql-database-using-php/#findComment-240332 Share on other sites More sharing options...
larry_boy_44 Posted April 28, 2007 Author Share Posted April 28, 2007 echo "<table width=\"100%\">"; while ($ArticleArray = mysql_fetch_array($ArticleResult, MYSQL_ASSOC)){ echo "<tr><td width=\"40%\" valign=\"top\">1. $ArticleArray[Title]</td> <td rowspan=\"2\"><font size=1>$ArticleArray[Description]</font></td></tr> <tr><td valign=\"top\">Release Date: $ArticleArray[Date]</td></tr>"; }; echo "</table>"; this is printing everything it should be printing once... 4 times... any ideas??? Link to comment https://forums.phpfreaks.com/topic/49050-problem-grabbing-more-than-1-row-of-data-from-mysql-database-using-php/#findComment-240350 Share on other sites More sharing options...
heckenschutze Posted April 28, 2007 Share Posted April 28, 2007 No, read the manual. But I'm guessing it's in there 4 times... Also "$ArticleArray[Title]", assumes 'title' is a constant (defined). It should be a string -> $ArticleArray['Title'] ;) Link to comment https://forums.phpfreaks.com/topic/49050-problem-grabbing-more-than-1-row-of-data-from-mysql-database-using-php/#findComment-240351 Share on other sites More sharing options...
larry_boy_44 Posted April 28, 2007 Author Share Posted April 28, 2007 figured it out... it is this part: Where ( Author_Article_Intersect.AuthorID = ' $AuthorID' And Author_Article_Intersect.ArticleID = Article.ArticleID ) I simply added: And Author_Article_Intersect = Author.AuthorID and it stopped giving me duplicate results... Link to comment https://forums.phpfreaks.com/topic/49050-problem-grabbing-more-than-1-row-of-data-from-mysql-database-using-php/#findComment-240355 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.