Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2011
    Posts
    1

    Unanswered: output info from database to layout

    first of all hi guys
    this is my first post here
    as you might think, I'm new to mysql
    well now related to my question
    I have a database created and I want that for each row to output some data in my php page
    in short
    my table is named info
    and has two columns, name and image
    now I want for each name to output something like this

    Code:
    <a href="page/{name}"><img src="images/{image}.jpg" onMouseOver="this.src='images/over.png';" onMouseOut="this.src='images/{image}.jpg';"></a>
    my mysql database looks like this


    Code:
    CREATE TABLE IF NOT EXISTS `info` (
      `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT 'game name',
      `image` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT 'image name',
      PRIMARY KEY (`name`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
    
    
    INSERT INTO `info` (`name`, `image`) VALUES
    ('Name 1', 'image1'),
    ('Name 2', 'image2'),
    ('Name 3', 'image3');
    now any ideas how can I do this
    again I'm new to this so no genius here

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    this isn't a mysql question, because the query that you want is dead simple...
    Code:
    SELECT name
         , image
      FROM info
    how to take that information and prepare your html from it, that's a php question
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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