Jump to content


Photo

Fetch User names


  • Please log in to reply
15 replies to this topic

#1 bondja

bondja
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 25 July 2006 - 09:27 PM

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.

#2 tomfmason

tomfmason
  • Staff Alumni
  • Advanced Member
  • 1,696 posts
  • Locationstealing your wifi

Posted 25 July 2006 - 09:38 PM

maybe this will help

<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>
<?php
include('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);
?>

hope this helps

Traveling East in search of instruction, and West to propagate the knowledge I have had gained.

current projects: pokersource

My Blog | My Pastebin | PHP Validation class | Backtrack linux


#3 bondja

bondja
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 25 July 2006 - 09:42 PM

Username Email some_info
Could not successfully run query (SELECT members) from DB: Unknown column 'members' in 'field list'

#4 tomfmason

tomfmason
  • Staff Alumni
  • Advanced Member
  • 1,696 posts
  • Locationstealing your wifi

Posted 25 July 2006 - 09:44 PM

Change the fields to the  relivant fields in your database.

Traveling East in search of instruction, and West to propagate the knowledge I have had gained.

current projects: pokersource

My Blog | My Pastebin | PHP Validation class | Backtrack linux


#5 bondja

bondja
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 25 July 2006 - 09:47 PM

hm...i guess i was wrong how much i know lol yea still wont work

#6 tomfmason

tomfmason
  • Staff Alumni
  • Advanced Member
  • 1,696 posts
  • Locationstealing your wifi

Posted 25 July 2006 - 10:06 PM

hm...i guess i was wrong how much i know lol yea still wont work


What error are you getting?

Traveling East in search of instruction, and West to propagate the knowledge I have had gained.

current projects: pokersource

My Blog | My Pastebin | PHP Validation class | Backtrack linux


#7 bondja

bondja
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 25 July 2006 - 10:06 PM

same thing as above

#8 tomfmason

tomfmason
  • Staff Alumni
  • Advanced Member
  • 1,696 posts
  • Locationstealing your wifi

Posted 25 July 2006 - 10:11 PM

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

Traveling East in search of instruction, and West to propagate the knowledge I have had gained.

current projects: pokersource

My Blog | My Pastebin | PHP Validation class | Backtrack linux


#9 bondja

bondja
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 25 July 2006 - 10:15 PM

My database is ladder, then in there i have members, and in members I have teamid and id etc.

#10 tomfmason

tomfmason
  • Staff Alumni
  • Advanced Member
  • 1,696 posts
  • Locationstealing your wifi

Posted 25 July 2006 - 10:19 PM

then change it to this

$sql = "SELECT teamid, whatever, some_info From members";

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.

Traveling East in search of instruction, and West to propagate the knowledge I have had gained.

current projects: pokersource

My Blog | My Pastebin | PHP Validation class | Backtrack linux


#11 tomfmason

tomfmason
  • Staff Alumni
  • Advanced Member
  • 1,696 posts
  • Locationstealing your wifi

Posted 25 July 2006 - 10:21 PM

you also need to change $rw['username'] to what ever you are searching for like $rw['teamid'] or what ever.

Traveling East in search of instruction, and West to propagate the knowledge I have had gained.

current projects: pokersource

My Blog | My Pastebin | PHP Validation class | Backtrack linux


#12 bondja

bondja
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 25 July 2006 - 10:22 PM

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 1

I 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>
<?php
include('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);
?>


#13 ryanlwh

ryanlwh
  • Staff Alumni
  • Advanced Member
  • 511 posts

Posted 25 July 2006 - 10:24 PM

remove the comma after teamid
Please use EDIT * 100...
Please use
or [php] * 1000...

PLEASE READ THE POSTED SOLUTIONS CAREFULLY * 1000000...

#14 tomfmason

tomfmason
  • Staff Alumni
  • Advanced Member
  • 1,696 posts
  • Locationstealing your wifi

Posted 25 July 2006 - 10:25 PM

beat me to it ryanlwh

Traveling East in search of instruction, and West to propagate the knowledge I have had gained.

current projects: pokersource

My Blog | My Pastebin | PHP Validation class | Backtrack linux


#15 bondja

bondja
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 25 July 2006 - 10:26 PM

lol thanks, now i dont have an error but it says i odnt have members now...but i do

#16 bondja

bondja
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 25 July 2006 - 11:16 PM

*cough*i've tried switching it so it would be like ID or name or teamid like in the field, still nothing




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users