duansao20000508 2013-10-10 17:37
浏览 94
已采纳

PHP / MYSQL到SESSION - 怎么做[关闭]

I am somewhat a noob on php, yet I have been trying for ages to solve this problem:

I have a MySQL ARRAY from which I want to extract data to put in a SESSION via a link. That should be pretty simple, but I’m going crazy trying to find the solution.

Here is what I’m trying to do:

ARRAY output:

Name – Country

James – Germany (link)

George – Mexico (link)

Tom – France (link)

Peter – Ireland (link)

On the end of each ARRAY output I want a link. And when the link is pressed the specific VARIABLE is sent to the SESSION and the user is also sent to a new page, where the SESSION will be picked up again.

The only VARIABLE I can manage to sent to the SESSION is always the last one, ex. “Peter – Ireland”, Even if I press on the link next to ex. George. Frustrating!!

What to do?

  • 写回答

1条回答 默认 最新

  • dongsui4658 2013-10-10 17:41
    关注

    You need to pass value in URL, no need of SESSION..

    If you take value in SESSION variable it always overwrite it. that's why you get the last value only. so better way is just pass the name and country in URL..

    <a href="yourpage.php?name=James&country=Germany">James – Germany</a>
    

    Then get the value of it on yourpage.php

    echo $_REQUEST['name'];    // James
    echo $_REQUEST['Country']; // Germany
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线