PhillNeedsHelp Posted April 16, 2008 Share Posted April 16, 2008 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 More sharing options...
wmguk Posted April 16, 2008 Share Posted April 16, 2008 we would really need to see all the code that you are using to see why? post the code for us, Link to comment https://forums.phpfreaks.com/topic/101329-php-only-showing-1-record/#findComment-518283 Share on other sites More sharing options...
PhillNeedsHelp Posted April 16, 2008 Author Share Posted April 16, 2008 <?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 } ?> Link to comment https://forums.phpfreaks.com/topic/101329-php-only-showing-1-record/#findComment-518288 Share on other sites More sharing options...
wmguk Posted April 16, 2008 Share Posted April 16, 2008 $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] Link to comment https://forums.phpfreaks.com/topic/101329-php-only-showing-1-record/#findComment-518291 Share on other sites More sharing options...
PhillNeedsHelp Posted April 16, 2008 Author Share Posted April 16, 2008 Thanks.. So any idea how to make it not select the one user? Link to comment https://forums.phpfreaks.com/topic/101329-php-only-showing-1-record/#findComment-518297 Share on other sites More sharing options...
wmguk Posted April 16, 2008 Share Posted April 16, 2008 if you just remove the WHERE string, then it will display every user in the database. Link to comment https://forums.phpfreaks.com/topic/101329-php-only-showing-1-record/#findComment-518300 Share on other sites More sharing options...
PhillNeedsHelp Posted April 16, 2008 Author Share Posted April 16, 2008 Hey then it shows every user in the users table and not the table for the forum.... Link to comment https://forums.phpfreaks.com/topic/101329-php-only-showing-1-record/#findComment-518303 Share on other sites More sharing options...
shikeh Posted April 16, 2008 Share Posted April 16, 2008 replace the "Where": instead of user, use forum select....form forum where forum=$selected_forum All the Best Shikeh Link to comment https://forums.phpfreaks.com/topic/101329-php-only-showing-1-record/#findComment-518337 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.