MySQL only returning one row - PLEASE HELP...

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
besly98
Forum Newbie
Posts: 15
Joined: Sun Feb 22, 2009 5:50 pm

MySQL only returning one row - PLEASE HELP...

Post by besly98 »

Hi all... this is my code and the sql is only pulling out 1 row... im baffled as to why. any ideas anyone?

<?


$sql3 = "SELECT * FROM wall WHERE id='".$userUNid."' ORDER BY orderid DESC LIMIT 3";
$results = mysql_query($sql3);
$arr = mysql_fetch_row($results);
$message = $arr[2];
$postid = $arr[3];


$sql2 = mysql_query("SELECT * FROM members WHERE id='".$postid."' ") or die ('Error: '.mysql_error ());
while($row = mysql_fetch_array($sql2))
{


echo "<h2 style='padding: 0px; margin: 15px 0px 7px 0px;'>Dougout</h2><div class='dogoutimg'><img src='http://www.jdbesly.co.uk/test/home/upload/";
echo $row['image'] ;
echo "' style='width: 60px;' /></div><div class='dougout' style='float: right;'>";
echo $message;
echo "</div>";
}

mysql_close($con);
?>


Report this post
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: MySQL only returning one row - PLEASE HELP...

Post by VladSun »

Assuming that you have a proper DB design, obviously it's because of the WHERE clause

WHERE id='".$userUNid."'

So, I don't think wall.id should be used.
There are 10 types of people in this world, those who understand binary and those who don't
besly98
Forum Newbie
Posts: 15
Joined: Sun Feb 22, 2009 5:50 pm

Re: MySQL only returning one row - PLEASE HELP...

Post by besly98 »

the ptoblem is that i have an image in another table im trying to link to an id in another table.... so if that id matchess the image id.. show that picture with the other id's mesage
Post Reply