Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display results of a joint query. How? 1

Status
Not open for further replies.

josel

Programmer
Oct 16, 2001
716
US
Looking around I learned how to create the join query

Code:
$data_query = '
SELECT a.* , b.MemberFirstName , b.MemberLastName FROM articles a , members b WHERE a.ArticleAuthor = b.MemberID
 LIMIT ' . $limit_start . ", " . $records_per_page;

$rh = mysql_query ($data_query);

//   TO DISPLAY THE RECORDS, I HAVE THIS    //

while ($row = mysql_fetch_array($rh))
{

$vContent = substr($row['a.ArticleContent'], 0, 125) .
 '... <br /> '. '<a border="0" class="link1" 
 href=javascript:ReadArticle("ReadArticle.php?Article=' . 
$row['a.ArticleID'] . '")> >>> Read this article >>></a>';

print '
<tr>
  <td style="background-color: #FFCC33" colspan="2">' . 
   $row['a.ArticleSubject'] . '
  </td>
</tr>
<tr>
  <td style="background-color: #FFFFCC" 
  width="310">By:&nbsp;&nbsp;' . $row['b.MemberFirstName'] . 
  $row['b.MemberLastname'] . '
  </td>
  <td style="background-color: #FFFFCC">' . 
  $row['a.ArticleDate'] . '
  </td>
</tr>
<tr>
  <td colspan="3">' .	$vContent . '
</td>
</tr>';
}

All the examples I was able to find talk about creating or running the query but none show how to print to stdo ...

Notice my failed attempt to use $row['a.ArticleDate'] and others like it ... Nothing is shown, not even a visible error.

What must I do?

Thank you all in advance for your usual help!


Jose Lerebours



KNOWLEDGE: Something you can give away endlessly and gain more of it in the process! - Jose Lerebours
 
Hi

Jose said:
Notice my failed attempt to use $row['a.ArticleDate'] and others like it ...
Noticed. That is wrong. So will not work. But is not incorrect. So you will get no error message.

You should spend more time with a MySQL tool, like... [tt]mysql[/tt]. That way you will see the reality : the table names and table aliases are not included in the column names.
Code:
$row['ArticleDate']

Feherke.
 
Well, at least one cannot say I was too far off.

Thanks,


Jose Lerebours


KNOWLEDGE: Something you can give away endlessly and gain more of it in the process! - Jose Lerebours
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top