อยากทราบว่า ตรงที่แสดงข้อมูล URL จะให้แสดงเฉพาะ id แค่ตัวเลข ต้องทำอย่างไงครับ

สำหรับผู้ที่ เริ่มต้น Programming - PHP มีอะไร แนะนำ หรือข้อสงสัยต้องบอร์ด นี้ คนที่มีความรู้ แบ่งปันคนอื่นบ้างนะ ปัญหาการเขียนโปรแกรม แบบ OOP Session Cookies php network

Moderator: mindphp, ผู้ดูแลกระดาน

makup
PHP Super Member
PHP Super Member
โพสต์: 398
ลงทะเบียนเมื่อ: 05/10/2020 10:02 am

อยากทราบว่า ตรงที่แสดงข้อมูล URL จะให้แสดงเฉพาะ id แค่ตัวเลข ต้องทำอย่างไงครับ

โพสต์ที่ยังไม่ได้อ่าน โดย makup »

108.JPG
อยากทราบว่า ตรงที่แสดงข้อมูล URL จะให้แสดงเฉพาะ id แค่ตัวเลข ต้องทำอย่างไงครับ และ ถ้าไม่เลือกข้อมูลอะไรเลยตรง listbox ให้แสดงตรงข้อมูล URL เป็น id 0 ต้องทำอย่างไรครับ
ภาพประจำตัวสมาชิก
mindphp
ผู้ดูแลระบบ MindPHP
ผู้ดูแลระบบ MindPHP
โพสต์: 41131
ลงทะเบียนเมื่อ: 22/09/2008 6:18 pm
ติดต่อ:

Re: อยากทราบว่า ตรงที่แสดงข้อมูล URL จะให้แสดงเฉพาะ id แค่ตัวเลข ต้องทำอย่างไงครับ

โพสต์ที่ยังไม่ได้อ่าน โดย mindphp »

ขอดูโค้ด ที่ สร้างฟอร์ม ก่อน ส่งค่ามาหน้านี้
ติดตาม VDO: http://www.youtube.com/c/MindphpVideoman
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
makup
PHP Super Member
PHP Super Member
โพสต์: 398
ลงทะเบียนเมื่อ: 05/10/2020 10:02 am

Re: อยากทราบว่า ตรงที่แสดงข้อมูล URL จะให้แสดงเฉพาะ id แค่ตัวเลข ต้องทำอย่างไงครับ

โพสต์ที่ยังไม่ได้อ่าน โดย makup »

mindphp เขียน: 22/10/2020 8:07 pm ขอดูโค้ด ที่ สร้างฟอร์ม ก่อน ส่งค่ามาหน้านี้
ตรงส่วนของ Form ครับ

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

@extends('layouts.master')                                  <!-- เป็นการดึง File Template ใน Folder layouts ใน File admin มาร่วมใช้งาน -->
@section('content')



<div class="table-responsive ">


    <h2>ตารางเที่ยวบิน</h2>
    <table class="table">
      <thead class="thead-dark">

     <form class="" method="get" action="/searchAirflight/search">
        <tr>
          <th scope="col">

            <br><br>ลำดับ</br></br></th>
          <th scope="col">
 
    <select name="name" id="name">
      <option selected="selected">---- เลือกทั้งหมด ----</option>
      @foreach($flight as $flights)
      <option value="{{$flights->id_airport}}" >{{$flights->airport['name']}}</option>
      @endforeach
    </select>

            <br><br>ชื่อที่ตั้งสนามบิน</br></br></th>
          <th scope="col">

            
    <select  name="name_airline" id="name_airline">
      <option selected="selected">---- เลือกทั้งหมด ----</option>
      @foreach($flight as $flights)
      <option value="{{$flights->airline['name_airline']}}">{{$flights->airline['name_airline']}}</option>
      @endforeach
    </select>

          <br><br>ชื่อสายการบิน</br></br></th>
          <th scope="col">

    <select name="path" id="path">
      <option selected="selected">---- เลือกทั้งหมด ----</option>
      @foreach($flight as $flights)
      <option value="{{$flights->path}}" >{{$flights->path}}</option>
      @endforeach
    </select>

            <br><br>เส้นทางการบิน</br></br></th>
          <th scope="col">

          <select name="date" id="date">
            <option selected="selected">---- เลือกทั้งหมด ----</option>
      @foreach($flight as $flights)
      <option value="{{$flights->date}}" >{{$flights->date}}</option>
      @endforeach
    </select>
            <br><br>วันที่</br></br></th>
          <th scope="col">

    <select name="timeout" id="timeout">
            <option selected="selected">---- เลือกทั้งหมด ----</option>
      @foreach($flight as $flights)
      <option value="{{$flights->timeout}}" >{{$flights->timeout}}</option>
      @endforeach
      </select>

          <br><br>เวลาออกเดินทาง</br></br></th>
          <th scope="col">

    <select name="price" id="price">
      <option selected="selected">---- เลือกทั้งหมด ----</option>
      @foreach($flight as $flights)
      <option value="{{$flights->price}}" >{{$flights->price}}</option>
      @endforeach
      </select>

            <br><br>ราคา</br></br></th>
          <th scope="col">

    <select name="model_aircraft" id="model_aircraft">
      <option selected="selected">---- เลือกทั้งหมด ----</option>
      @foreach($flight as $flights)
      <option value="{{$flights->model_aircraft}}" >{{$flights->model_aircraft}}</option>
      @endforeach
      </select>
            <br><br>รุ่นเครื่องบิน</br></br></th>
          <th scope="col">

         
                
            <button type="submit" name="submit" class="btn btn-primary" name="submit">ค้นหา</button>
       
          

            <br><br>แก้ไข</br></br></th>
          <th scope="col">
            <br><br>ลบ</br></br></th>
        </tr>
      </form>
        
      </thead>
      <tbody>
        <?php $number = 1; ?>
        @foreach($flight as $flights)
        <tr>
          <th scope="row">{{$number}}</th>
          <td>{{$flights->airport['name']}}</td>
          <td>{{$flights->airline['name_airline']}}</td>
          <td>{{$flights->path}}</td>
          <td>{{$flights->date}}</td>
          <td>{{$flights->timeout}}</td>
          <td>{{$flights->price}}</td>
          <td>{{$flights->model_aircraft}}</td>
          
          
          <td>
            <a href="/editAirflight/{{$flights->id}}" class="btn btn-primary">แก้ไข</a>
          </td>
          
          <td>
            <a href="/deleteAirflight/{{$flights->id}}" onclick="return confirm('คุณต้องการลบข้อมูลหรือไม่ ?')" class="btn btn-danger">ลบข้อมูล</a>
          </td>
        </tr>
        <?php $number++; ?>
        @endforeach
        
      </tbody>

       <tbody>
        <?php $number = 1; ?>

        
        
      </tbody>

    </table>

    <div class="d-flex flex-column flex-md-row align-items-center p-3 px-md-4 mb-3 bg-white border-bottom shadow-sm">
      <a href="/createAirflight" class="btn btn-primary">เพิ่มข้อมูล</a>


       

     </div>

     {{$flight->appends(['search'=>request()->query('search')])->links()}}
    </div>
  
  @endsection
ภาพประจำตัวสมาชิก
mindphp
ผู้ดูแลระบบ MindPHP
ผู้ดูแลระบบ MindPHP
โพสต์: 41131
ลงทะเบียนเมื่อ: 22/09/2008 6:18 pm
ติดต่อ:

Re: อยากทราบว่า ตรงที่แสดงข้อมูล URL จะให้แสดงเฉพาะ id แค่ตัวเลข ต้องทำอย่างไงครับ

โพสต์ที่ยังไม่ได้อ่าน โดย mindphp »

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

 <option selected="selected">---- เลือกทั้งหมด ----</option>
แกเป็น

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

 <option value="0" selected="selected">---- เลือกทั้งหมด ----</option>
และ

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

<option value="{{$flights->airline['name_airline']}}">{{$flights->airline['name_airline']}}</option>
เปลี่ยน เป็นค่า id ของชื่อนั้นแทน $flights->airline['name_airline']
ติดตาม VDO: http://www.youtube.com/c/MindphpVideoman
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
ตอบกลับโพส
  • Similar Topics
    ตอบกลับ
    แสดง
    โพสต์ล่าสุด

ผู้ใช้งานขณะนี้

สมาชิกกำลังดูบอร์ดนี้: ไม่มีสมาชิกใหม่ และบุคลทั่วไป 64