Hi all,
I'm using a while loop and looping through data in a database.
When I loop through, instead of looping through once it loops through several times.
How can I get it to just loop once per field for each user?

$query = 'SELECT persinfo.userId, persinfo.url, persinfo.email, men.password FROM persinfo, men where pass_id = 1';

$result = mysql_query($query) or die (mysql_error());

$row = mysql_fetch_array($result);

foreach ($row as $myrow )
{
	echo $myrow . '<br>';
}

Thanks

Recommended Answers

All 2 Replies

I'm sorry, I should say it echo's out the users's info several times instead of once per user.

Member Avatar for rajarajan2017

follow these after $result:

if (mysql_num_rows($result) > 0) { 
  while($row = mysql_fetch_row($result)) { 
    echo $row[0] . "<br/>";
    echo $row[1] . "<br/>";
  }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.