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.
Page 2 of 2 FirstFirst 12
Results 16 to 19 of 19
  1. #16
    New Coder
    Join Date
    Oct 2010
    Posts
    56
    Thanks
    2
    Thanked 0 Times in 0 Posts
    It seems to work, although I don't have a table that matches the data yet. I'll try to throw one together.

    Note: You did have 1 typo -
    PHP Code:
    while ($row mysql_fetch_array($result
    PHP Code:
    while ($row mysql_fetch_array($result)) 
    I post that just for anyone reading this/potentially using your example, I'm not nitpicking your assistance. Thanks again.

  2. #17
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,652
    Thanks
    80
    Thanked 4,638 Times in 4,600 Posts
    Use your own table and your own columns!

    Since you didn't give us any real example to work with, I had to make one up.

    I showed the basics: How to sort text and date and number columns. Just clone those sort functions and rename them/adapt them to match your data.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  3. #18
    Banned
    Join Date
    Dec 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    // Column name => column value
    $filter = array(
    'city' => $city,
    'text' => $text,
    'group' => $group,
    );

    $filter_sql = 'WHERE ';
    foreach ($filter as $key=>$value)
    $filter[$key] = "MATCH ($key) AGAINST ('$value') ";

    $filter_sql .= implode($filter, ' AND ');

    $query = "SELECT * FROM Posts
    $filter_sql
    ORDER by Date DESC LIMIT $limit_posts OFFSET $first_post";

  4. #19
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,652
    Thanks
    80
    Thanked 4,638 Times in 4,600 Posts
    Rajdeep's naser *MIGHT* work, *IF* you have created a full text index for your table.

    But it's way OVERKILL for the simple kind of query filtering needed here.

    It's really a bad answer, overall.

    Rajdeep: This answer is not a very good advertisement for your "Web Development Services". It would certainly make me suspect that you wouldn't do the best development job for me.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


 
Page 2 of 2 FirstFirst 12

Posting Permissions

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