[請益] $_GET[] 字串取代

看板PHP作者 (deparis)時間15年前 (2009/01/14 00:01), 編輯推噓2(204)
留言6則, 4人參與, 最新討論串1/1
請教大家 test.php?idx=3&app=4 我要將index 跟 app這2個變數的值傳給test.php 當作資料庫query用的條件 $parent = $db->getArray(" SELECT col1,col2 FROM table WHERE index =3 AND application =4 "); 目前條件寫死在裡面,run ok! 但我想改成由網址列那邊給參數,來改變 index & application的值 爬文得知是要用 echo _$GET['idx']; (有印出網址列的3) echo _$GET['app']; 但是怎麼把 echo_$GET['idx']; ==>置換成SELECT句子的"3"呢? 還請大家指點。 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 123.192.17.62

01/14 00:10, , 1F
WHERE index = {$_GET['idx']}
01/14 00:10, 1F

01/14 00:10, , 2F
AND application = {$_GET['app']}
01/14 00:10, 2F

01/14 00:14, , 3F
{$_GET['idx']}? 我試了,不行吶?
01/14 00:14, 3F

01/14 00:23, , 4F
where index = '".$_GET['idx']."'
01/14 00:23, 4F

01/14 00:29, , 5F
tks!it works.
01/14 00:29, 5F

01/14 00:43, , 6F
$sql=sprintf('WHERE `index` = %d', $_GET['idx']);
01/14 00:43, 6F
文章代碼(AID): #19RBhJSP (PHP)