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
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题