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

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
bbazbazooka
Forum Newbie
Posts: 3
Joined: Thu Jul 10, 2008 1:18 pm

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

Post 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
 
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

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

Post 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.
bbazbazooka
Forum Newbie
Posts: 3
Joined: Thu Jul 10, 2008 1:18 pm

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

Post by bbazbazooka »

thanks mate :D

ps:

i will come with more problems :banghead:
bbazbazooka
Forum Newbie
Posts: 3
Joined: Thu Jul 10, 2008 1:18 pm

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

Post 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! :))
Post Reply