Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Banned
    Join Date
    Sep 2011
    Posts
    140
    Thanks
    17
    Thanked 0 Times in 0 Posts

    echoing a MySQL field

    How can I echo a field from a MySQL database in PHP?

    +----+---------------+------------+---------+-------+-------+-------+--------+----------+
    | id | primarycolour | pricerange | country | sizes | sizem | sizel | sizexl | category |
    +----+---------------+------------+---------+-------+-------+-------+--------+----------+
    | 1 | Black | 1 | Italy | 2 | 1 | 1 | 3 | Belts |
    | 2 | Blue | 2 | USA | 1 | 0 | 0 | 2 | Belts |
    +----+---------------+------------+---------+-------+-------+-------+--------+----------+
    For example, how would I echo the country field for id 2?

  2. #2
    Master Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    5,092
    Thanks
    109
    Thanked 602 Times in 589 Posts
    PHP Code:
    $Query "select country from <tablename> where id='2'";

    $Result mysql_query($Query);

    $Row mysql_fetch_array($Result);

    print 
    $Row['country']; 
    You could also use mysql_result to simplify things but its been a while since I've used that and frankly I can't remember how to.
    Quote Originally Posted by deathshadow View Post
    So seriously, loosen up that tie, let out the belt, and try relating to normal people on the street instead of the gentleman's club crowd.

  3. Users who have thanked tangoforce for this post:

    Democrazy (09-11-2011)

  4. #3
    Banned
    Join Date
    Sep 2011
    Posts
    140
    Thanks
    17
    Thanked 0 Times in 0 Posts
    Hey tangoforce, the code worked so I'd like to publicly thank you.

    Thank you.


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •