Hello everyone,

Im once having problems trying to retrieve information from one of my tables.

I have a table with the following information:

CREATE TABLE `island2` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `user` int(11) NOT NULL default '0',
  `island` int(11) NOT NULL default '0',
  `town` int(11) NOT NULL default '0',
  `village` int(11) NOT NULL default '0',
  `islandrank` int(11) NOT NULL default '0',
  `townrank` int(11) NOT NULL default '0',
  `villagerank` int(11) NOT NULL default '0',
  `game` int(11) NOT NULL default '0',
  `dateregistered` int(11) NOT NULL default '0',
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=6366 ;

I am able to retrieve the information as basic but the problem is I need to somehow match the [user] number above to match up to the [id] number below and then display the [username] in the list.

CREATE TABLE `members2` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `username` varchar(16) NOT NULL default '',
  `password` varchar(32) NOT NULL default '',
  `display_name` varchar(20) NOT NULL default '',
  `display_prem` text NOT NULL,
  `points` int(11) NOT NULL default '4000',
  `age_check` tinyint(4) NOT NULL default '0',
  `rank` tinyint(4) NOT NULL default '0',
  `hunger_level` int(11) NOT NULL default '7',
  `viewed_update` tinyint(4) NOT NULL default '0',
  `referer` varchar(16) NOT NULL default '0',
  `game` int(11) NOT NULL default '0',
  `location` varchar(32) NOT NULL default '',
  `post_count` int(11) NOT NULL default '0',
  `global_post_count` int(11) NOT NULL default '0',
  `active_pet` int(11) NOT NULL default '0',
  `premium` tinyint(4) NOT NULL default '0',
  `verify` tinyint(1) NOT NULL default '1',
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=81 ;

This is what I have tried and it doesnt seem to work :O( And so I would apreciate any feedback or help. Thanks

$interactive = 1;
$page_title = "TEST ISLAND";
$rank_check = 1;
include "header.inc.php";


$game=$_GET['game'];


// Get all the data from the "example" table
$result = mysql_query("SELECT * FROM island2 WHERE island ='1' AND town ='1' AND village ='1'") 
or die(mysql_error());  

$memberdata = mysql_query("SELECT user FROM island2 WHERE island = '1' AND town = '1' AND village = '1'")
$member = fetch("SELECT username FROM members2 WHERE $memberdata=$userid");




echo "<p align=center>&nbsp;</p>
<p align=center>&nbsp;</p>
<p align=center><b><font face=Arial size=5>VILLAGE 1</font></b></p>
<p align=center>&nbsp;</p>
<p align=center><a href=http://www.cyberpetworld.com/1village.pro.php>Join 
This Village</a></p>
<p align=center>&nbsp;</p>
<p align=center>&nbsp;</p>
<p align=center><b><u>Village Members Listed Here</u></b></p>
<p align=center>&nbsp;</p>";



echo "<center><table border='1'>";
echo "<tr> <center><th>Name</th> </tr>";
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
	// Print out the contents of each row into a table
	echo "<tr><td>"; 
	echo $row['user'];
	echo "</td></tr>"; 
} 

echo "</table>";

?>

Thanks

Justin

Recommended Answers

All 2 Replies

I think you have missed the semi colon here:

$memberdata = mysql_query("SELECT user FROM island2 WHERE island = '1' AND town = '1' AND village = '1'")

Heya,

Thanks. I seem to get this message when I tried that: Parse error: syntax error, unexpected T_VARIABLE in /home/cyberwor/public_html/1village.php on line 17 :>/

Justin

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.