[PHP] info from two tables?

YEy i has custom title^_^
Joined
Sep 29, 2006
Messages
451
Reaction score
69
i would like know is it possible to load info from two tables like, from first table it loads level and character ID (since theres no character name in same place whit levels) then load name for that ID from other table, e.x 40010502 is charid and character is 40lvl, so i would like know hes name too (since bunch of codes looks kinda fag) so on other table i see charid,name,place,coordinates but not level.
So thats why i need load info from two tables.

If anyone understands what im trying to say...
So if this is possible just tell me, pl0z
 
Well i didnt do the database :/...
But both tables do have same CharID for spefic character but only other got name, and other level. (smart db made by chineses xD)
 
Well then it isn't too hard:
PHP:
$result1 = mysql_query("SELECT * FROM table 1 where charid = 'something'");
$result2 = mysql_query("SELECT * FROM table 2 where charid = 'something'");

It could probably be put into one string, but I can't arsed checking if it can. But you probably get the idea.
 
Well, yeah atm its working whit one spefic charId.. im trying find out how i could make it show Top 10 Level characters... heres the codex0r so far :)
If anyone knows what i mean once again help would be nice (<3 i am such a leecher boy<3)

PHP:
<?php
$connect = odbc_connect("****", "****", "****");
$query = "SELECT wLevel FROM CHAR_POWER WHERE dwCharID = '406099187'";
$query2 = "SELECT szNickName FROM CHAR_BASIC WHERE dwCharID = '406099187'";
$result = odbc_exec($connect, $query);
$result2 = odbc_exec($connect, $query2);
while(odbc_fetch_row($result)){
  $Level = odbc_result($result, 1);
  $Name = odbc_result($result2, 1);
  echo "Name: ";
  print("$Name, $Level");
  echo " Level";
}
odbc_close($connect);

?>
 
Error, My code:
PHP:
$neekeri = "SELECT szNickName, wLevel ".
"FROM CHAR_BASIC, CHAR_POWER ". "ORDER BY wLevel DESC LIMIT 0,10";

And error:

Code:
Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near 'LIMIT'.
 
Back