dtjpnd7517 2015-06-26 00:18
浏览 191
已采纳

如何在URL中传递多个值的另一个页面[关闭]

As the title explains it, how can i pass multiple value to antoher page in URL. i have used the method before but only with a single value, i cant get it work with multiple. I know that you should place ampersand & to glue variables together.

This is currently my code:

<a href='update.php?del=$id?name=$loginname' class='sexybutton'>Print Bon</a>

I get the $id however i cant get the $loginname for some reason.

This is the code i use to get the data from the url

include 'dbconnect.php';

     // Get name
     $loginname = $_GET['name'];
     $sql1 = "SELECT * FROM users WHERE name='$name' ";    
     if ($conn->query($sql1) === TRUE) {   
    {       
    $name = $row['name'];
    echo $name; //Outputs: 2
     }

     // Get ID
     $id = $_GET['del'];
     // Update database
     $sql = "UPDATE wp_wppizza_orders SET printed='1' WHERE id='$id' ";
     if ($conn->query($sql) === TRUE) {
     echo " ";
     } else {
     echo "Error updating record: " . $conn->error;
}

As i mentioned, the GET id works but the GET name doesnt.

it gives 3 seperate warnings

Notice: Undefined index: name in C:\xampp\htdocs\login\update.php on line 5

Notice: Undefined variable: name in C:\xampp\htdocs\login\update.php on line 6

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\login\update.php on line 7

  • 写回答

2条回答 默认 最新

  • dslh32311 2015-06-26 00:19
    关注
    update.php?del=$id?name=$loginname
    

    to

    update.php?del=$id&name=$loginname
    

    The first parameter is marked by ?, all following parameters are seperated by &

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

报告相同问题?

悬赏问题

  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程
  • ¥20 模型在y分布之外的数据上预测能力不好如何解决
  • ¥15 processing提取音乐节奏
  • ¥15 gg加速器加速游戏时,提示不是x86架构
  • ¥15 python按要求编写程序
  • ¥15 Python输入字符串转化为列表排序具体见图,严格按照输入
  • ¥20 XP系统在重新启动后进不去桌面,一直黑屏。
  • ¥15 opencv图像处理,需要四个处理结果图
  • ¥15 无线移动边缘计算系统中的系统模型