duanchendu69495 2011-10-21 00:57
浏览 26
已采纳

如何在查看当前发布的PHP MYSQL时显示来自同一类别的其他帖子的链接

Im having trouble with an mySQL Query .What i need is a query that will display on the same page where im viewing a post a list of links to posts in the same category on the side of the page.Im almost finished a music site similar to youtube where users can listen to a track and see a list of tracks beside the post that are in the same category. Any Information Ive found on this is just related to Wordpress pluggins which im not using. My Database Tables are

        Table_categories
           cat_id
           cat_name 

        Table - Mixes
           mix_id
           mix_subject
           mix_description
           mix_date
           mix_cat -- mix_cat is the foreign key for categories.cat_id

The cat_id of Categories is linked to the foreign key mix_cat in table Mixes.I Know it has something to do with ?id= number of the id in one of the table,s Cheers guys Thanks for your help Trevor

  • 写回答

1条回答 默认 最新

  • duanbu9345 2011-10-21 01:11
    关注

    You could try something like

    Select * from Table_Mixes where id={insert id here, don`t forget to force the int type to avoid SQL Injection}
    

    Get the row and now you have a $mix object with a mix_cat property (or $mix['mix_cat'], if you get it as an array).

    Now you just

    select * from Table_Mixes where mix_cat={insert $mix->mix_cat here} order_by {whatever} limit {how many links?}
    

    and build the links.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 运动想象脑电信号数据集.vhdr
  • ¥15 三因素重复测量数据R语句编写,不存在交互作用
  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目