2017-02-25 68 views
-1

我使用php創建超鏈接,並在超鏈接單擊時傳遞3個參數。我的問題與下面的語法是,只有第一個參數傳遞,其他2被忽略。所有參數未通過

我應該在下面的語法中更改什麼,以便所有3個參數都能通過?

if($number_of_rows > 0) { 
    echo '<table border="1">'; 
    echo '<tr>'; 
    echo ' <th bgcolor="#FFFFFF" >Name </th>'; 
    echo ' <th bgcolor="#FFFFFF">User ID </th>'; 
    echo ' <th bgcolor="#FFFFFF">Dollar Amt </th>'; 
    echo ' <th bgcolor="#FFFFFF">Price 1 </th>'; 
    echo ' <th bgcolor="#FFFFFF">Price 2 </th>'; 
    echo ' <th bgcolor="#FFFFFF">Price 3 </th>'; 
    echo ' <th bgcolor="#FFFFFF">Price 4 </th>'; 
    echo ' <th bgcolor="#FFFFFF">Items Sold </th>'; 
    echo ' <th bgcolor="#FFFFFF">Items On Sale</th>'; 
    echo '</tr>'; 

while ($Row = mssql_fetch_assoc($result)) 
{ 
    echo '<tr><td>' . $Row['Name'] . '</td><td>' . $Row['User ID'] . 
    '</td><td>' . "$".round($Row['Dollar Amt']) . '</td><td>' . "$".round($Row['Price 1']) . 
    '</td><td>'. "$".round($Row['Price 2']) . '</td><td>'. "$".round($Row['Price 3']) . 
    '</td><td>'. "$".round($Row['Price 4']) . '</td><td>' . $Row['Items Sold'] . 
    '</td><td><a href="Test.php?name='.$Row['Name'].'"&begin=".$begin"&finish=".$finish>'.$Row['Items On Sale'].'</a></td></tr>'; 
} 

以上運行sql server存儲過程,我使用echo創建表並返回到我的頁面。該過程按其應有的方式工作。唯一的問題是,只有名稱被傳遞到網址,而不是我想要傳遞的2個日期。

不是一個重複的,這是針對mysql和我正在使用mssql。此外,鏈接的重複會談到返回行,現在傳遞參數。我的問題是,只有名稱參數被傳遞時單擊。請刪除重複的標誌。

編輯
的變量定義,像這樣:

$begin = $_GET['begin']; 
$end = $_GET['end']; 
+0

的可能的複製[?而($行=的mysql \ _fetch \ _array($結果)) - 正在執行多少循環]( http://stackoverflow.com/questions/2974011/while-row-mysql-fetch-arrayresult-how-many-loops-are-being-performed) – Matt

+0

你的列名中有空格,這是不好的做法 - 你應該用查詢中的勾號來包裝它們。沒有看到這個問題,我正在進行一場瘋狂的猜測,並猜測它的問題。 – Qirel

+0

我覺得問題/代碼是不完整的。你是否試圖通過插入/更新/刪除/選擇? –

回答

0

你混合雙引號"和單引號'。將while循環中代碼的最後一行替換爲以下內容,它應該按預期工作。

'</td><td><a href="Test.php?name='.$Row['Name'].'&begin='.$begin.'&finish='.$finish.'">'.$Row['Items On Sale'].'</a></td></tr>'; 

從您的文章編輯,試試這個:

'</td><td><a href="Test.php?name='.$Row['Name'].'&begin='.$begin.'&finish='.$end.'">'.$Row['Items On Sale'].'</a></td></tr>'; 
+0

通過開始,並通過文本結束,但不是值 – IcyPopTarts

+0

@IcyPopTarts不完整的代碼。試試這個。我看不到'$ begin'和'$ finish'變量被定義。 ''​​'.$Row['Items On Sale'].'';' – rmalviya

+0

@malviya - 我應該顯示哪些代碼? – IcyPopTarts