|
 |
|
อยากถามเรื่องวิธีการใช้ $_SERVER[PHP_SELF] ในการส่งค่าในหน้าเดียวกันเอง |
|
 |
|
|
 |
 |
|
form????
|
 |
 |
 |
 |
Date :
2011-11-08 13:24:54 |
By :
Dragons_first |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
<a href="<?=$_SERVER[PHP_SELF]?>?sortS=username">Test</a>
<a href="?sortS=username2">Test2</a>
|
 |
 |
 |
 |
Date :
2011-11-08 13:36:38 |
By :
ผ่านมา |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองทั้งสามแบบแล้วครับ ค่าไม่เข้าไปใน $sortS เลย (echo ค่าออกมาแล้วว่างเปล่า)
|
 |
 |
 |
 |
Date :
2011-11-08 13:52:41 |
By :
Guest |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เอ....หรือว่าผมเรียกค่าตัวแปรผิดวิธีหว่า
การเก็บค่าตัวแปรด้วยวิธี้สามารถเรียกใช้ตรงๆเลยได้ใช่ไหมครับ เช่น
Code (PHP)
echo "$sortS";
หรือ
Code (PHP)
$sql="select * from table where X order by $sortS";
หรือว่าต้องเรียกใช้ด้วยวิธีอื่น
|
 |
 |
 |
 |
Date :
2011-11-08 14:14:30 |
By :
Guest |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เห่อๆสงสัยต้องโม้กันนิดนึง
ใน php.ini จะมีการกำหนดค่า environment ที่ชื่อว่า register_globals
โดย default จะมี่ค่า เป็น Off เพื่อความปลอดภัย(เค้าว่างั้น)
เมื่อวันมี่ค่า เป็น Off ตัวแปรที่ส่งมาแบบ get หรือ post จะไม่สามารถเรียกใช้ได้เลยมันจะเก็บอยู่ในตัวแปร
$_GET กับ $_POST จะรับค่าเอา หรือ เอาไปใช้เลยก็ได้
case นี้เป็นแบบ get ก็เป็น
$sortS=$_GET[sortS];
หรือ เอา $_GET[sortS] ไปใช้เลย
|
 |
 |
 |
 |
Date :
2011-11-08 14:19:51 |
By :
ผ่านมา |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณทุกคนครับ ในที่สุดก็ได้แล้ว
ต้อง get , post ค่าเวลาใช้งานแม้เป็นไฟล์เดียวกัน
ขอบคุณครับ
|
 |
 |
 |
 |
Date :
2011-11-08 14:23:55 |
By :
จขกท |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|