|
 |
|
ถ้าผมจะทำ GET ข้อมูล id shop ของ db มาในช่องลิงค์ทำไงครับ |
|
 |
|
|
 |
 |
|
ไม่มี code มาเปะ ให้ดูหน่อยหรอครับ
Code (PHP)
// code select ข้อมูล
$query1 = "SELECT * FROM table";
$result1 = mysqli_query($objCon,$query1) or die ("xxxx");
$resultdata = mysqli_fecth_array($result1);
//ตัวนี้อาจจะทำเป็นแบบ while ครับ เพื่อให้ได้ข้อมูลออกมาทั้งหมด
1.เอาข้อมูลที่ query มาใส่ใน link
เช่น
Code (PHP)
<a href="page.php?id=<?php echo $resultdata['id_shop'];?>">คลิกเพื่อดูรายละเอียด</a>
กรณีที่ ข้อมูลเป็นการ while ตัว id=เปลี่ยนไปตามข้อมูลของมันครับ
เช่น
เมื่อเราเอาเมาส์ไปชี้ที่ลิงก์รายละเอียดของ สบู่ id=1
แต่พอเราเอาเมาส์ไปชี้ที่รายละเอียดของ ยาสีฟัน id=2
ข้อสังเกตุ ให้สังเกตุที่มุมล่างซ้ายของหน้าจอ browser มันจะขึ้นบอกเลยครับว่ากำลังจะส่งอะไร
2.หน้ารับข้อมูล
จะเป็นอีกหน้า
เมื่อคลิกที่ link แล้ว จะมีการส่งค่า method ผ่านตัว id
อย่างแรกคือให้เรารับค่ามันมาก่อนในหน้าที่ 2
Code (PHP)
$idshop == $_GET['id'];
เมื่อรับค่าอาจจะเช็คดูอีกที่ว่ารับถูกไหมหรือว่าส่งค่ามาหรือป่าวก็แค่
Code (PHP)
echo $idshop;
หรือจะใช้พวก isses emty อะไรก็ว่ากันไปแล้วแต่สไตล
3.เมื่อรับข้อมูลได้แล้วให้นำมา select โดยใช้เงื่อนไขในการแสดงครับ
Code (PHP)
// code select ข้อมูล
$query1 = "SELECT * FROM table WHERE table_id = '$idshop'";
$result1 = mysqli_query($objCon,$query1) or die ("xxxx");
$resultdata = mysqli_fecth_array($result1);
แล้วก็ทดสอบแสดงข้อมูลออกมาครับ
ข้อมูลที่แสดงถ้าเป็นไปตามเงื่อนไขก็จะแสดงแค่ข้อมูลที่เราเลือกดูรายละเอียดครับ
เช่น ถ้าเราคลิกที่รายละเอียด สบู่
ข้อมูลในหน้านี้ก็จะแสดงแค่สบู่ครับ
รายละเอียดที่เอามาแสดงอาจเป็น
ียีห้อ
ราคา
วันหมดอายุ
วิธีใช้
รายละเอียดอื่นๆ
|
 |
 |
 |
 |
Date :
2019-02-06 09:28:02 |
By :
nobetaking |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
THX
|
 |
 |
 |
 |
Date :
2019-02-06 21:25:02 |
By :
mokong123 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 01
|