Author Topic: Where am I going wrong?  (Read 691 times)

Offline Jbye

  • Level 5
  • *
  • Posts: 19
  • Reputation: +0/-0
    • View Profile
Where am I going wrong?
« on: June 29, 2010, 12:46:57 PM »
I am trying to recall a name of a ship from my database.  I can recall it but i'm just recalling the value.  Let me explain....

My user is user 10----the stat for ship owned is stat 3------the ship he owns is number 1.

I have put number 1 in the values for the user and the return value above is just 1 and not the ship name.

Users
10    w    5db1799938479bd448f61ca335e0549c         0    0    NULL
User_stats
7    10    3    hello - this was me just testing
Stats
3    Ship Owned    shipo
Ships
2    Bloh    trader    10

If i change above in user stats where i've put hello to 2 I want it to return bloh trader.
What am i doing wrong?
Hope i've explained it well enough.

Offline Nox

  • Level 35
  • **
  • Posts: 738
  • Reputation: +12/-2
    • View Profile
Re: Where am I going wrong?
« Reply #1 on: June 29, 2010, 12:56:28 PM »
You didn't include SQL queries

If ships are core part of the game - although I favor EAV in this I'd go for just 3-table
user (id, ...) - user_ships (id_user, id_ship) - ships (id, ...)

Code: [Select]
SELECT name FROM ships WHERE id IN (SELECT id_ship FROM user_ships WHERE id_user=$id)
Meet us at an IRC irc.freenode.net #bbg as well
Enjoy http://spiritbeacon.noxart.cz/ !

Offline Sunchaser

  • Game Owner
  • Level 22
  • *
  • Posts: 274
  • Reputation: +2/-0
  • Game Owner
    • View Profile
    • Medieval Europe
Re: Where am I going wrong?
« Reply #2 on: June 30, 2010, 03:01:03 AM »
Remember before to sanitize the parameter $id.

http://www.phpro.org/tutorials/Filtering-Data-with-PHP.html


 


SimplePortal 2.3.3 © 2008-2010, SimplePortal