Need this to show more than 1 result from a table

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
Monotoko
Forum Commoner
Posts: 64
Joined: Fri Oct 26, 2007 4:24 pm

Need this to show more than 1 result from a table

Post by Monotoko »

Hi guys below you will find an extract from a game script i have made

Code: Select all

if ($hello=="")
{
echo "IP doesnt exist";
}
else
{
echo "You were able to ping something, the open ports on this server are displayed below";

$result = mysql_query("SELECT * FROM ports
WHERE ip='$ip'");

while($row = mysql_fetch_array($result))
  {
$ports = $row['port'];
  }
echo $ports;
}
Now, there are multiple entries in the table for each ip, yet it is only showing me one, i would like it to show them all, how would i go about this?

Thank You
~Monotoko
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Echoing during the loop, not after, is a simply way.
Monotoko
Forum Commoner
Posts: 64
Joined: Fri Oct 26, 2007 4:24 pm

Post by Monotoko »

thanks, that did it
Post Reply