|
 |
|
รบกวนอีกทีนะครับ คือผมทำ Friendly URl แล้วต้องการ include ไฟล์ต่าง ๆ มาโชว์ที่หน้า index แต่พแมี / มันก็ไม่มาโชว์ครับ |
|
 |
|
|
 |
 |
|
มันได้เข้า statement ตัวนั้นหรือเปล่าครับ
Code (PHP)
{
echo "Debug";
include('contact.php?id=3');
}
|
 |
 |
 |
 |
Date :
2011-03-08 08:22:52 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
หมายถึงว่าใส่ debug ในนี้ใช่มั้ยครับ
Code (PHP)
elseif($_SERVER['REQUEST_URI'] == "/contact/3.html") //ตรงนี้มันไม่ออกมาโชว์ที่หน้า index อ่ะครับ
{echo "Debug";
include('contact.php?id=3');} //มันเด้งออกไปโชว์ที่หน้าของมันเอง(contact.php)
ลองแล้ว แสดงว่ามันไม่เข้า statement ตรงนี้นะครับ มันก็เด้งไปหน้า contact เหมือนเดิม
แล้วทำไมมันถึงไม่เข้าล่ะครับ
งงเลย
|
 |
 |
 |
 |
Date :
2011-03-08 08:43:36 |
By :
เด็กโง่ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมลองวิธีนี้ดูครับ
Code (PHP)
$url = $_SERVER['REQUEST_URI'];
echo $_SERVER['REQUEST_URI']; ///ผลได้ contact/3.html
list($category, $id, $num) = split('[/.]', $url);
echo $category."<br>"; //ผลได้ค่าว่าง
echo $id."<br>"; //ผลได้ contact
echo $num."<br>"; //ผลได้ 3
switch ( $id )
{
case 'contact':
require_once 'contact.php?id='. $num;
exit;
break;
case 'test':
require_once 'test.php';
exit;
break;
}
ถ้า test เข้าก็ได้ผลลัพธ์ปกติครับ
แต่พอ contact เข้ากลับไม่ได้ครับ กลับเด้งไปหน้า contact
|
 |
 |
 |
 |
Date :
2011-03-08 09:03:01 |
By :
เด็กโง่ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
คุณ if อย่างไร ค่าเป็นอะไรมันก็ได้อย่างนั้นครับ ตรวจสอบค่าให้ดี ๆ ครับ 
|
 |
 |
 |
 |
Date :
2011-03-08 09:26:30 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมลองดูแล้วครับก็ยังไม่ได้ หรือวิธีคิดจะผิดก็ไม่รู้ ผมลองเอาโค้ดของพี่มาแก้
Code (PHP)
<?
header('HTTP/1.1 200 OK');
echo $_SERVER['REQUEST_URI'];
//*** Link Page ***//
echo "<hr>";
echo "<a href=/hello/2.html>Hello PHP</a> , <a href=/config.html>Config PHP</a> , <a href=/install.html>Install PHP</a>";
echo "<hr>";
//*** Include Content ***//
if($_SERVER['REQUEST_URI'] == "/hello/2.html")
{
require("hello.php");
}
elseif($_SERVER['REQUEST_URI'] == "/config.html")
{
require("config.php");
}
elseif($_SERVER['REQUEST_URI'] == "/install.html")
{
require("install.php");
}
else
{
// Default include;
}
?>
มันก้ยังไม่ได้อยู่ดีครับ คลิกที่ Hello PHP มันก้เด้งไปหน้า Hello เลยไม่ include เข้ามา
ลองวิธีนี้
Code (PHP)
<?
header('HTTP/1.1 200 OK');
echo $_SERVER['REQUEST_URI'];
//*** Link Page ***//
echo "<hr>";
echo "<a href=/hello/2.html>Hello PHP</a> , <a href=/config.html>Config PHP</a> , <a href=/install.html>Install PHP</a>";
echo "<hr>";
//*** Include Content ***//
list($category,$id,$i) = split('[/.]',$_SERVER['REQUEST_URI']);
echo $category."<br>";
echo $id."<br>";
echo $i;
switch ( $id )
{
case 'hello':
require_once 'hello.php';
exit;
break;
case 'config':
require_once 'config.php';
exit;
break;
}
?>
แยกคำได้ hello แต่ทำไมมันไม่ดึงไฟล์มาก็ไม่รู้ กลับเด้งไปหน้า hello แทน
คลิกที่ config ก็ include เข้ามาปกตินะครับ
งานก็ด่วน ตันก็ตัน
ช่วยทีครับ
|
 |
 |
 |
 |
Date :
2011-03-08 16:27:15 |
By :
เด็กโง่ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
if($_SERVER['REQUEST_URI'] == "/webboard.html")
{ include('webboard.php');}
elseif($_SERVER['REQUEST_URI'] == "/test.html")
{ include('test.php');}
else($_SERVER['REQUEST_URI'] == "/contact/3.html") //ตรงนี้ลองให้มันพ้น 2 เงื่อนไขบนดูครับ
{ include('contact.php?id=3');}
|
 |
 |
 |
 |
Date :
2011-03-09 10:47:23 |
By :
compeng |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 01
|