douzhang7184 2014-03-25 10:20
浏览 13
已采纳

如何显示我从地址栏中获得的字段?

how do I display a field when I have used a GET command to get it from the address bar from the previous page and then display it in my table?

I have tried to display the field already in the table but no luck. the field is call "Reference"

using the below I want to get the reference into the table. (I have tried the following echo "" . $row['$Reference'] . "";)

http://test.com/searchresults.php?Reference=456789 $Reference=$_GET['Reference'];

search results page

<?php

require_once('auth.php');

$host=""; // Host name 
$username=""; // Mysql username
$password=""; // Mysql password 
$db_name=""; // Database name 
$tbl_name="Physio"; // Table name 

 // Connect to server and select database.
   mysql_connect($host, $username, $password)or die("cannot connect"); 
   mysql_select_db($db_name)or die("cannot select DB");

   // get value of Reference that sent from address bar
 $Reference=$_GET['Reference'];

  $sql="SELECT * FROM $tbl_name WHERE Reference='$Reference'";
 $result=mysql_query($sql);

 $rows=mysql_fetch_array($result);

    if(!isset($_POST['postcode'])) {
  header ("location:index.php");
 } 
     echo "<p> Results </p>" ;
 $search_sql = "SELECT * FROM `Physio` WHERE Postcode like '%" . $_POST['postcode'] . "%'";
$search_query = mysql_query($search_sql);

while ($search_rs = mysql_fetch_array($search_query))
{
echo"<table><tr>" ;
     echo '<th>Reference</th><th>Select</th><th>PhysioReference</th><th>Physio</th><th>Postcode</th><th>Line1</th><th>Tel</th>';
while ($search_rs = mysql_fetch_array($search_query))
     {
     echo '<tr>';
     echo "<td>" . $row['$Reference'] . "</td>";
     echo "<td><a href=\"Physiotoinstruction.php?Reference={$search_rs['Reference']}\">Select</a></td>";
     echo "<td>".$search_rs['PhysioReference'] . "</td>";
     echo "<td>".$search_rs['Name'] . "</td>";
     echo "<td>".$search_rs['Postcode'] . "</td>";
     echo "<td>".$search_rs['Line1'] . "</td>";
     echo "<td>".$search_rs['Tel'] . "</td>";
     echo '</tr>';
     }
  echo '</table>';
}
if (!empty($search_rs))
{
echo "<p> Results Found </p>" ;
}
else
{
    echo "<p> No Results Found </p>" ;
}

   ?>
  • 写回答

3条回答 默认 最新

  • doushi5752 2014-03-25 10:22
    关注

    Variables will not expand when in single quotation marks, and also you're trying to access variable called $row which isn't in scope (i.e. doesn't exist at this point). The following should suffice:

    $rows[$Reference]
    

    Or change $rows to $row earlier in your code, whichever makes most sense semantically.

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

报告相同问题?

悬赏问题

  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路