Jump to content

problem grabbing more than 1 row of data from MySQL database using PHP


larry_boy_44

Recommended Posts

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...

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

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???

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...

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.