bondja Posted July 25, 2006 Share Posted July 25, 2006 Hey, I just got this script for a gaming ladder for like $10 bucks, and it was good bargain but I'm wanting to add features to it, right now i'm trying to figure out how to fetch the user names from the mysql database and put them in the table. I know what the code means and I understand it, i just don't know how to lpace it together, help would be amazing. Quote Link to comment https://forums.phpfreaks.com/topic/15627-fetch-user-names/ Share on other sites More sharing options...
tomfmason Posted July 25, 2006 Share Posted July 25, 2006 maybe this will help[code=php:0]<table border="0" width="100%"> <tr> <td width="33%"><b>Username</b></td> <td width="33%"><b>Email</b></td> <td width="34%"><b>some_info</b></td> </tr><?phpinclude('db.php');$sql = "SELECT username, email, some_info From your_table";$get_users = mysql_query($sql);if (!$get_users) { echo "Could not successfully run query ($sql) from DB: " . mysql_error(); exit;}if (mysql_num_rows($get_users) == 0) { echo " <td><font color=\"#FF0000\">*Your have no members</font></td>"; include('yourpage.php'); exit;} while ($rw = mysql_fetch_assoc($get_users)) { echo ' <tr> <td width="33%">' . $rw['username'] . '</td> <td width="33%">' . $rw['email'] . '</td> <td width="34%">' . $rw['some_info'] . '</td> </tr>';}mysql_free_result($get_users);?>[/code]hope this helps Quote Link to comment https://forums.phpfreaks.com/topic/15627-fetch-user-names/#findComment-63654 Share on other sites More sharing options...
bondja Posted July 25, 2006 Author Share Posted July 25, 2006 Username Email some_info Could not successfully run query (SELECT members) from DB: Unknown column 'members' in 'field list' Quote Link to comment https://forums.phpfreaks.com/topic/15627-fetch-user-names/#findComment-63657 Share on other sites More sharing options...
tomfmason Posted July 25, 2006 Share Posted July 25, 2006 Change the fields to the relivant fields in your database. Quote Link to comment https://forums.phpfreaks.com/topic/15627-fetch-user-names/#findComment-63659 Share on other sites More sharing options...
bondja Posted July 25, 2006 Author Share Posted July 25, 2006 hm...i guess i was wrong how much i know lol yea still wont work Quote Link to comment https://forums.phpfreaks.com/topic/15627-fetch-user-names/#findComment-63660 Share on other sites More sharing options...
tomfmason Posted July 25, 2006 Share Posted July 25, 2006 [quote author=bondja link=topic=101845.msg403455#msg403455 date=1153864078]hm...i guess i was wrong how much i know lol yea still wont work[/quote]What error are you getting? Quote Link to comment https://forums.phpfreaks.com/topic/15627-fetch-user-names/#findComment-63669 Share on other sites More sharing options...
bondja Posted July 25, 2006 Author Share Posted July 25, 2006 same thing as above Quote Link to comment https://forums.phpfreaks.com/topic/15627-fetch-user-names/#findComment-63670 Share on other sites More sharing options...
tomfmason Posted July 25, 2006 Share Posted July 25, 2006 Unknown column 'members' in 'field list' this means that you do not have a field members. Maybe you meant for this to be a table members. Check your database table and see if you have a field named members Quote Link to comment https://forums.phpfreaks.com/topic/15627-fetch-user-names/#findComment-63673 Share on other sites More sharing options...
bondja Posted July 25, 2006 Author Share Posted July 25, 2006 My database is ladder, then in there i have members, and in members I have teamid and id etc. Quote Link to comment https://forums.phpfreaks.com/topic/15627-fetch-user-names/#findComment-63674 Share on other sites More sharing options...
tomfmason Posted July 25, 2006 Share Posted July 25, 2006 then change it to this[code=php:0]$sql = "SELECT teamid, whatever, some_info From members";[/code]of course you will change this throughout the script. After the SELECT you put what you are searching for in the database and after FROM is the table that you are searching. Quote Link to comment https://forums.phpfreaks.com/topic/15627-fetch-user-names/#findComment-63675 Share on other sites More sharing options...
tomfmason Posted July 25, 2006 Share Posted July 25, 2006 you also need to change $rw['username'] to what ever you are searching for like $rw['teamid'] or what ever. Quote Link to comment https://forums.phpfreaks.com/topic/15627-fetch-user-names/#findComment-63677 Share on other sites More sharing options...
bondja Posted July 25, 2006 Author Share Posted July 25, 2006 Could not successfully run query (SELECT teamid, From members) from DB: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'From members' at line 1I have<table border="0" width="100%"> <tr> <td width="33%"><b>Username</b></td> <td width="33%"><b>Email</b></td> <td width="34%"><b>some_info</b></td> </tr><?phpinclude('config.php');$sql = "SELECT teamid, From members";$get_teamid = mysql_query($sql);if (!$get_teamid) { echo "Could not successfully run query ($sql) from DB: " . mysql_error(); exit;}if (mysql_num_rows($get_teamid) == 0) { echo " <td><font color=\"#FF0000\">*Your have no members</font></td>"; include('html.php'); exit;} while ($rw = mysql_fetch_assoc($get_teamid)) { echo ' <tr> <td width="33%">' . $rw['teamid'] . '</td> <td width="33%">' . $rw['email'] . '</td> <td width="34%">' . $rw['some_info'] . '</td> </tr>';}mysql_free_result($get_teamid);?> Quote Link to comment https://forums.phpfreaks.com/topic/15627-fetch-user-names/#findComment-63678 Share on other sites More sharing options...
ryanlwh Posted July 25, 2006 Share Posted July 25, 2006 remove the comma after teamid Quote Link to comment https://forums.phpfreaks.com/topic/15627-fetch-user-names/#findComment-63680 Share on other sites More sharing options...
tomfmason Posted July 25, 2006 Share Posted July 25, 2006 beat me to it ryanlwh Quote Link to comment https://forums.phpfreaks.com/topic/15627-fetch-user-names/#findComment-63682 Share on other sites More sharing options...
bondja Posted July 25, 2006 Author Share Posted July 25, 2006 lol thanks, now i dont have an error but it says i odnt have members now...but i do Quote Link to comment https://forums.phpfreaks.com/topic/15627-fetch-user-names/#findComment-63684 Share on other sites More sharing options...
bondja Posted July 25, 2006 Author Share Posted July 25, 2006 *cough*i've tried switching it so it would be like ID or name or teamid like in the field, still nothing Quote Link to comment https://forums.phpfreaks.com/topic/15627-fetch-user-names/#findComment-63713 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.