1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Select Limit Where

Discussion in 'PHP' started by lektrikpuke, Feb 23, 2008.

  1. #1
    $query = "SELECT * FROM tbl_name".
    //" LIMIT $offset, $rowsPerPage".
    " WHERE column1 LIKE '%".$keywords[$i]."%'".
    " OR column2 LIKE '%".$keywords[$i]."%'" .
    " OR column3 LIKE '%".$keywords[$i]."%'" .
    " OR column4 LIKE '%".$keywords[$i]."%'" .
    " OR column5 LIKE '%".$keywords[$i]."%'" .
    " OR column6 LIKE '%".$keywords[$i]."%'" .
    " OR column7 LIKE '%".$keywords[$i]."%'" .
    " OR column8 LIKE '%".$keywords[$i]."%'" .
    " OR column9 LIKE '%".$keywords[$i]."%'" .
    " OR column10 LIKE '%".$keywords[$i]."%'" .
    " ORDER BY column1";

    I have a working search (of sorts) that uses the above code. I have been trying to implement pagination into the results, and when I uncomment the line " LIMIT $offset, $rowsPerPage"., I receive an error message. Note: $offset and $rowsPerPage are declared and initialized.

    Any help please?
     
    lektrikpuke, Feb 23, 2008 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    The LIMIT should go at the very end of the query.
     
    nico_swd, Feb 23, 2008 IP
  3. lektrikpuke

    lektrikpuke Well-Known Member

    Messages:
    297
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    113
    #3
    Figured it out. Put LIMIT at the end of the query. Thanks any way. =)
     
    lektrikpuke, Feb 23, 2008 IP
  4. lektrikpuke

    lektrikpuke Well-Known Member

    Messages:
    297
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    113
    #4
    Thanks nico_swd, just figured it out. I wish I'd just posted it earlier. I've dabbled with it (I won't say how long, just trust me, it was a period of time) for a while.
     
    lektrikpuke, Feb 23, 2008 IP