Doomflame Posted May 10, 2003 Share Posted May 10, 2003 I told it to select username from phpbb_users, and it should select multiple values. how would i make these values print on the page? I need all of them to print. Here is the code i have so far in case it helps: $mysql = mysql_connect("localhost", "doomflam_admin", "PASSWORD") or die("Could Not Connect To Database!"); mysql_select_db("doomflam_forum"); $query = "SELECT username FROM phpbb_users"; $setquery = mysql_query($query); $res = mysql_fetch_array($setquery); foreach($res as $key => $value) { print "$value <br>"; } And this outputs: Doomflame Doomflame Doomflame is the first username in the list, but i need it to list all of them. Quote Link to comment https://forums.phpfreaks.com/topic/455-help-me-please-im-not-very-good-with-mysql/ Share on other sites More sharing options...
BK87 Posted May 11, 2003 Share Posted May 11, 2003 Try this: [php:1:6823e43252]<?php //Databaseinfo $database=\"db\"; $db = mysql_connect(\"localhost\",\"user\",\"pass\"); mysql_select_db($database); //Code $listm = mysql_query(\"SELECT * FROM contest_users\") or die (mysql_error()); while ($row = mysql_fetch_array($listm)) { print(\"$row->username\"); } ?>[/php:1:6823e43252] Use $row to select the row that you want, like username, or pass... Hope it helps Quote Link to comment https://forums.phpfreaks.com/topic/455-help-me-please-im-not-very-good-with-mysql/#findComment-1542 Share on other sites More sharing options...
Doomflame Posted May 11, 2003 Author Share Posted May 11, 2003 nope, this time it didn\'t show any names. Quote Link to comment https://forums.phpfreaks.com/topic/455-help-me-please-im-not-very-good-with-mysql/#findComment-1543 Share on other sites More sharing options...
BK87 Posted May 11, 2003 Share Posted May 11, 2003 try this it works on my box.. as a matter a fact I\'m using it [php:1:eca989abab]<?php //Settings $server=\"localhost\"; $database=\"db\"; $username=\"user\"; $pass=\"pass\"; $table=\"table\"; //Code $db = mysql_connect($server,$username,$pass\"); mysql_select_db($database); $list = mysql_query(\"SELECT * FROM $table\") or die (mysql_error()); while ($row = mysql_fetch_array($list)) { print(\"$row[usernme]\"); } ?>[/php:1:eca989abab] Again chage username to what ever field you have.. this works on my box, if it don\'t on yours, then I suggest you get another one. Quote Link to comment https://forums.phpfreaks.com/topic/455-help-me-please-im-not-very-good-with-mysql/#findComment-1544 Share on other sites More sharing options...
metalblend Posted May 11, 2003 Share Posted May 11, 2003 Try this: $mysql = mysql_connect("localhost", "doomflam_admin", "PASSWORD") or die("Could Not Connect To Database!"); mysql_select_db("doomflam_forum",$mysql) or die("Unable To Locate Database!"); $query = "SELECT username FROM phpbb_users"; $setquery = mysql_query($query) or die("Query failed!"); if (mysql_num_rows($setquery)>0) { while ($res = mysql_fetch_array($setquery)) { print $res[\'username\']."<br>rn"; } } else { print "There are no entries!"; } Hope that helps. You can break it down if you need to customize it.. let us know if you need more help. edit // posted late.. either method will work. Quote Link to comment https://forums.phpfreaks.com/topic/455-help-me-please-im-not-very-good-with-mysql/#findComment-1545 Share on other sites More sharing options...
Doomflame Posted May 11, 2003 Author Share Posted May 11, 2003 metalblend, thanks it works!!!!!!!!!!!!!! Quote Link to comment https://forums.phpfreaks.com/topic/455-help-me-please-im-not-very-good-with-mysql/#findComment-1546 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.