User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 427,376 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,989 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 488 | Replies: 2
Reply
Join Date: Dec 2007
Posts: 71
Reputation: justted is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
justted justted is offline Offline
Junior Poster in Training

SELECT and RETRIEVE MYsql Data...

  #1  
Mar 28th, 2008
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
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2007
Location: Cavite,Philippines
Posts: 508
Reputation: ryan_vietnow is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 68
ryan_vietnow's Avatar
ryan_vietnow ryan_vietnow is offline Offline
Posting Pro

Re: SELECT and RETRIEVE MYsql Data...

  #2  
Mar 28th, 2008
I think you have missed the semi colon here:

  1. $memberdata = mysql_query("SELECT user FROM island2 WHERE island = '1' AND town = '1' AND village = '1'")
"death is the cure of all diseases..."
http://ryantetek.wordpress.com
Reply With Quote  
Join Date: Dec 2007
Posts: 71
Reputation: justted is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
justted justted is offline Offline
Junior Poster in Training

Re: SELECT and RETRIEVE MYsql Data...

  #3  
Mar 28th, 2008
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
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 3:58 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC