country repeating different recordset - very new to PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jarv
Forum Newbie
Posts: 13
Joined: Thu Jun 26, 2008 10:02 am

country repeating different recordset - very new to PHP

Post by jarv »

Result1 country is just showing CHINA CHINA CHINA
CHINA is the first country in the Headertbl table

Code: Select all

<?php
include_once("config.php");
include_once("functions.php");
// Check user logged in already:
// checkLoggedIn("yes");
doCSS(); ?>
<div id="header">
<p class="wrap">
 
<? print("\n <a href=\"post.php"."\">+ Add new header</a> ");?>
</p>
<h1 class="wrap">Avert Weekly Headers</h1>
</div>
<?
include_once("config.php");
$result = mysql_query("SELECT * FROM Headertbl ORDER BY HeaderDate DESC");
 
 
while($row = mysql_fetch_array($result))
 
 
{
echo '<div id="entry" class="wrap">';
$HeaderID = $row['HeaderID'];
$HeaderImage = $row['HeaderImage'];
$HeaderDate = $row['HeaderDate'];
$HeaderPhotoNo = $row['HeaderPhotoNo'];
$HeaderName = $row['HeaderName'];
$PhotoID = $row['PhotoID'];
$CountryID = $row['CountryID'];
 
 
 
$result1 = mysql_fetch_array(mysql_query("SELECT * FROM Headertbl LEFT JOIN country ON Headertbl.CountryID = country.CountryID "));
$Country = $result1['country'];
 
echo <<<EOF
  <div class="entry_header">
    <b>Header Name:</b> $HeaderName <a href="edit.php?HeaderID=$HeaderID">Edit Header</a> | <a href="delete.php?HeaderID=$HeaderID">Delete Header</a><br />
     <a href="upload.php?HeaderID=$HeaderID">Change Header</a><br />
      <a href="http://www.avert.org/photo_search.php?search_keyword_id=&search_country_id=country-$CountryID&page_type=thumbnails&search=search">Other pictures from $Country</a><br />
    <b>PhotoID:</b> $PhotoID <br />
    <b>Header Photo No:</b> $HeaderPhotoNo <br />
    <b>Header Date:</b> $HeaderDate <br />
    <img src="headers/$HeaderImage">
  </div>
EOF;
echo '</div>';
}
 
mysql_close($link);
?>
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: country repeating different recordset - very new to PHP

Post by Christopher »

Look into the SQL keyword DISTINCT and/or the GROUP BY clause...
(#10850)
Post Reply