Jump to content

PHP only showing 1 record


PhillNeedsHelp

Recommended Posts

Hey I have made this forum system that displays the users details (username, avatar etc) which is stored in the users table. I have then displayed that info using <?php include('user-info.php'); ?> it displays it but only displays 1 record when there are loads of records... any ideas? Thanks

Link to comment
https://forums.phpfreaks.com/topic/101329-php-only-showing-1-record/
Share on other sites

<?php
  
$dbh=mysql_connect ("localhost", "usersl", "pass") or die ('I cannot connect to the database because: ' . mysql_error());
        mysql_select_db ("phil_forum"); 


   $query = "SELECT username, forum  FROM forum WHERE question=$id";
    $result = mysql_query ($query) or trigger_error("Query: $query\n<br />Mysql error: " . mysql_error());

    while($row = mysql_fetch_array($result)) {
     $un = $row['user_name'];

     include('user-info.php');
    
}
?>

That's the forum reply script.. Heres the user-info

 

<?php
$dbh=mysql_connect ("localhost", "user", "pass") or die ('I cannot connect to the database because: ' . mysql_error());
     mysql_select_db ("phil_useraccounts");

   $query = "SELECT user_name, user_id, motto, badge, user_group FROM users WHERE user_name='$un'";
   $result = mysql_query ($query) or trigger_error("Query: $query\n<br />Mysql error: " . mysql_error());

    while($row = mysql_fetch_array($result)) {

   $user = $row['user'];

  echo '<img src="http://www.mysite.com?user=' .$user. '&action=&direction=2&head_direction=2&size=1&img_format=gif"><img 


}
?>

   $query = "SELECT user_name, user_id, motto, badge, user_group FROM users WHERE user_name='$un'";
[code]
[/quote]

The WHERE says user_name='$un' so im assuming that it will only display the info for the one user, with the one username?

or am i on the wrong lines here?

[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.