Good morning! :)
I have a select statement that is returning the correct results but is looping the retrieved data over and over....
This is what I have:
Code:
<?php
$id = $_GET['id'];
$result = mysql_query("SELECT jobs.job_title,jobs.date,jobs.id,users.full_name,users.id FROM `jobs`,users WHERE jobs.user_id = $id ORDER BY job_title DESC LIMIT 10") or die(mysql_error());
echo "<table border='1'>";
echo "<tr> <th>Job Title</th> <th>Date Added</th> </tr>";
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
// Print out the contents of each row into a table
echo "<tr><td>";
echo $row['job_title'];
echo "</td><td>";
echo $row['date'];
echo "</td></tr>";
}
echo "</table>";
?>
The result that it is returning looks something like this:
Job Title Date Added
Web Developer 2011-02-17
Web Developer 2011-02-17
Web Developer 2011-02-17
Sales Rep 2011-02-15
Sales Rep 2011-02-15
Sales Rep 2011-02-15
PHP Programmer 2011-03-07
PHP Programmer 2011-03-07
PHP Programmer 2011-03-07
Accountant 2011-02-15
As you can see it displays each record 3 times and then the next and so forth.
Any ideas how to change this would be highly appreciated.
Thank you in advance.