สอบถามเรื่องจะ GET ID จากฐานข้อมูลของ phpBB

กฎการใช้บอร์ด
คำถามหมวดนี้ ควรระบุ รายละเอียดของ Server OS, เวอร์ชั่น ของ PHP, CMS ที่ท่านใช้
รวมถึง Hosting หรือ Control Panel Hosting

ตอบกระทู้

รูปแสดงอารมณ์
:icon_plusone: :like: :plusone: :gfb: :-D :) :( :-o 8O :? 8) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: :angry: :baa: :biggrin:
รูปแสดงอารมณ์อื่นๆ

BBCode เปิด
[img] เปิด
[url] เปิด
[Smile icon] เปิด

กระทู้แนะนำ
   

มุมมองที่ขยายได้ กระทู้แนะนำ: สอบถามเรื่องจะ GET ID จากฐานข้อมูลของ phpBB

Re: สอบถามเรื่องจะ GET ID จากฐานข้อมูลของ phpBB

โดย thatsawan » 12/07/2017 5:02 pm

ก้อ หลังจาก insert เราได้ id มา เเล้ว เรามาทำเป็นลิงค์

----

หลังจากนั้นเราต้อง Get id จาก ลิงค์มา select * from --- where id นั้น

Re: สอบถามเรื่องจะ GET ID จากฐานข้อมูลของ phpBB

โดย AePongsak » 12/07/2017 4:53 pm

ไม่เข้าใจตรงเอาค่าไอดีมาอ่าครับ ต้องเอามาตอนหลัง Insert หรอครับ

โค้ด: เลือกทั้งหมด

$sql_ary = array(
    'SELECT' => '*',
    'FROM' => array(
    'phpbb_taxi_con' => 't',
    ),
 'WHERE'        => 'id'
);

$sql = $db->sql_build_query('SELECT', $sql_ary);
$result = $db->sql_query($sql);

while ($row = $db->sql_fetchrow($result)) {
    $template->assign_vars(array(
        'LABEL_ID2' => $id,
        'LABEL_NAME2' => $row['name'],
        'LABEL_DISTANCE2' => $row['distance'],
        'LABEL_STOP_TIME2' => $row['stop_time'],
        'LABEL_PRICE2' => $row['price'],
    ));
} 

Re: สอบถามเรื่องจะ GET ID จากฐานข้อมูลของ phpBB

โดย thatsawan » 12/07/2017 4:24 pm

รับค่าไอดีนั้น เเล้วมา select เเล้ว หยิบมาเเสดงสิ

สอบถามเรื่องจะ GET ID จากฐานข้อมูลของ phpBB

โดย AePongsak » 12/07/2017 4:23 pm

ตอนนี้ถ้าคลิกตรง URL ได้ id ตามที่เลือกแล้วแต่จะทำไงข้อมูลจากไอดีนั้นมาแสดงด้วย

โค้ด: เลือกทั้งหมด

<table class="table1">
                                <thead>
                                        <tr>
                                                <th>ID</th>
                                                <th>NAME</th>
                                                <th>DISTANCE</th>
                                                <th>STOP TIME</th>
                                                <th>PRICE</th> 
                                        </tr>
                                </thead>
                                <!-- BEGIN row -->
                                <tr class="bg1" >
                                        <td  style="text-align: center;"><a href="taxi_rate.php?action=showid&id={row.LABEL_ID}">{row.LABEL_ID}</a></td>
                                        <td style="text-align: center;">{row.LABEL_NAME}</td>
                                        <td style="text-align: center;">{row.LABEL_DISTANCE}</td>
                                        <td style="text-align: center;">{row.LABEL_STOP_TIME}</td>
                                        <td style="text-align: center;"><b>{row.LABEL_PRICE}</b></td>
                                </tr>

                                <!-- END row -->

                        </table>

ข้างบน