Jump to content

get similar posts


doddsey_65

Recommended Posts

im trying to run a query which will get posts from the database that have tags similar to the current ones.

Unfortunatly the echoed result isnt displaying as it should.

 

$query = $link->query("SELECT t.*, p.* 
                                FROM ".TBL_PREFIX."topics t
                                JOIN ".TBL_PREFIX."posts p
                                ON (p.p_tid = t.t_tid)
                                WHERE t.t_name = '".decode_url($_GET['t_name'])."'
                                LIMIT 1")
                                or die(print_link_error());
            $row = $query->fetch(PDO::FETCH_ASSOC);
            
            $tag_query = $link->query("SELECT p_name
                                    FROM ".TBL_PREFIX."posts
                                    WHERE MATCH (p_tags) 
                                    AGAINST ('".$row['p_tags']."' IN BOOLEAN MODE)
                                    ")or die(print_link_error());
            $result = $tag_query->fetch();
            
            foreach($result as $key => $value)
            {
                echo 'Name = '.$result[$key]['p_name'].'<br />';
            }

 

i have done a dump of result and it shows:

 

$ => Array (2)
(
    ['p_name'] = String(12) "File Updates"
    ['0'] = String(12) "File Updates"
)

 

but there should only be one item in this array(p_name).

I dont know where the second is coming from. The query has pulled the right results, it just isnt displaying it right.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.