Page 1 of 1

php and mysql [and some F&*(uP commands]

Posted: Thu Jul 10, 2008 1:42 pm
by bbazbazooka
Hello to all

I want to make a profile page for my players but i dont know how can i make this command to work

so:

Code: Select all

SELECT * from characters WHERE name(SELECT login from accounts where login='$login');
 
Where $login is the name of the account


So....

I want something like this [ if someone know of corse]

I want to select all of the character for the account "kilimangearo" for exemple.

the function is this:

Code: Select all

 
<?php
$conn = mysql_connect("localhost","root","password");
if (!$conn)
  {
  die('Could not connect: ' . mysql_error());
  }
 
mysql_select_db("adb", $conn);
 
$result = mysql_query("SELECT * from characters WHERE name(SELECT login from accounts where login='$login')");
 
 
 
while($row = mysql_fetch_array($result))
  {
 
 
echo $row['acct'];
 
  }
 
mysql_close($conn);
?>
 
Thank you all!

EDIT:

I found out

Code: Select all

 
 
<?php
$conn = mysql_connect("localhost","root","password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
 
mysql_select_db("adb", $conn);
 
$result = mysql_query("SELECT name FROM characters, accounts WHERE accounts.login ='$login' AND accounts.acct = characters.acct ORDER BY name");
 
 
 
while($row = mysql_fetch_array($result))
  {
 
echo $row['name'];
 
  }
 
mysql_close($conn);
?> 
 
 
 

EDIT2:

Okay but now, i don't know how to separte the results:

Code: Select all

 
AsdgasdfBazGasdTesgzxcvTrollwar
 
I need to put it like this:

Code: Select all

 
Asdgasdf
Baz
Gasd
Tesgzxcv
Trollwar
 

Re: php and mysql [and some F&*(uP commands]

Posted: Thu Jul 10, 2008 3:03 pm
by jaoudestudios
You can just put html around your php.
i.e...

Code: Select all

 
echo $row['name']."<br>";
 
Would be the easiest option, but not the best for accessibility. It should really be a list, but depends on what you plan on doing with it. I would not worry too much about that now. So just use the line break. Or you could put <p> DATA </p> around the result.

Re: php and mysql [and some F&*(uP commands]

Posted: Thu Jul 10, 2008 4:08 pm
by bbazbazooka
thanks mate :D

ps:

i will come with more problems :banghead:

Re: php and mysql [and some F&*(uP commands]

Posted: Fri Jul 11, 2008 3:54 am
by bbazbazooka
hello again

Another problem:

[this is the command]

Code: Select all

 
SELECT name,guid,friend_guid FROM characters,accounts,social_friends WHERE accounts.login='baz' and accounts.acct = characters.acct AND characters.guid = social_friends.character_guid AND social_friends.friend_guid;
 

Code: Select all

 
+------+-------+-------------+
| name | guid  | friend_guid |
+------+-------+-------------+
| Baz  | 19822 |       19789 |
+------+-------+-------------+
1 row in set
 
Now i have to take the friend_guid and look in characters and the command must match the guid from characters and instend of his guid [friends_guid and characters.guid] to give his name...
thanks

S&*t, my head hurts :) but i love it! :))