Results 1 to 2 of 2

Thread: SQL Database

  1. #1
    Join Date
    Feb 2013

    SQL Database

    Hi, I have a problem. When im wrting the code in php I put it like this:


    $sql = "SELECT wines.id, regions.name AS region, wines.name, color, year, price FROM wines, regions WHERE regions.id = wines.region_id ORDER BY year"
    $query = mysql_query($sql);

    while ($row = mysql_fetch_assoc($query)) {

    <td> <?php echo $row['id'];?> </td>
    <td> <?php echo $row['name'];?> </td>
    <td> <?php echo $row['region'];?> </td>
    <td> <?php echo $row['color'];?> </td>
    <td> <?php echo $row['year'];?> </td>


    In the browser It appears everything right like the table is with the : Id, name, color, year, price and regions. But Can you tell me How can I choose a Particular color in the $sql part of the code so that I am able to display only that color items in the table?
    I already tried to set it "..., color=1,..." but it doesn't work very well.
    The color are in type "enum('Red','White','Rose') So 1, 2 and 3.

  2. #2
    Join Date
    Aug 2004
    You mean something like this?
    . . . WHERE regions.id = wines.region_id AND color = 'red' . . .
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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