duanju8308 2015-11-28 13:07
浏览 47
已采纳

将朋友GET ID传递给另一个页面

I have asked this question before but I couldn't understand the answer maybe because it didn't work for me.

I have a developed a chat application. Once a user submits using keyup, it works well i.e inserted into database and also selected just fine and the message is even displayed. The page being refreshed by javascript is load.php which has php code doing the selection like this;

SELECT * FROM chat WHERE sender_id=$_SESSION['id']

This is working just fine. But when I change it to

SELECT * FROM chat WHERE sender_id=$_SESSION['id'] AND receipent_id=$_GET['id']

it is not working simply because the $_GET['id'] of a selected member in the home page is not being passed to the load.php which is being refreshed by javascript every .....milliseconds so that online messages of the session id and the selected member should show in the message display. I refresh the load.php using this code on the home page;

function refresh(){ 
    setTimeout (function(){ 
        $('#message').load('load.php'); 
        refresh(); 
    }, 2000);
} 

working just fine.

Now this load.php must select for me messages only for the member selected in the home page. So how can I have this members' id passed on to this load.php on selecting from database?

Will be so grateful for your help programmers.

  • 写回答

3条回答 默认 最新

  • douhuan1497 2015-11-28 13:14
    关注

    If you want to pass $_GET['id'] value try to add in your function this value

    function refresh(){ setTimeout (function(){ 
        $('#message').load('load.php?id=<?php echo $_GET['id']; ?>');
        refresh(); }, 2000);
    }
    

    Then load.php will have get value

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 组策略中的计算机配置策略无法下发
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)