How to retrieve data on site from mysql using php - help needed

Discussion in 'PHP' started by hope2life, Aug 7, 2012.

  1. #1
    Hello,
    I know how to retrieve data from mysql but I have a specific need.

    Here is the code I am using

    include('connection.php');
    $query="SELECT * FROM products WHERE cat1='Baby Swing'";
    $result=mysql_query($query) or die('query failed');
    $row=mysql_fetch_array($result);

    There are 10 rows in table with baby swing as cat1

    productname is another field in the table where cat1="Baby Swing"

    I want to retrieve and print only productname in the 4th row of all 10 baby swing rows selected from above query
    I don't want to retrieve all productname using php while loop.

    Is that possible using something like php array?

    Any help would be greatly appreciated.


    Thanks!
     
    Last edited: Aug 7, 2012
    hope2life, Aug 7, 2012 IP
  2. Bhuvan14

    Bhuvan14 Peon

    Messages:
    18
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Try this Query, it ill take exact 4th row of the table.

    SELECT column name FROM table name LIMIT 1 OFFSET 3

    LIMIT 1 - select only one row

    OFFSET - take after 3rd row of the table...

    Try this.. It ill help you
     
    Bhuvan14, Aug 8, 2012 IP
  3. hope2life

    hope2life Active Member

    Messages:
    1,641
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    90
    #3
    ok Thanks! it worked
     
    hope2life, Aug 8, 2012 IP