รบกวนแก้ code ให้หน่อยค่ะ

เริ่มโดย test_one, 26 มกราคม 2012, 01:20:25

หัวข้อก่อนหน้า - หัวข้อถัดไป

0 สมาชิก และ 1 ผู้มาเยือน กำลังดูหัวข้อนี้

test_one

<form id="dateCarGroup" name="dateCarGroup"  method="post" action="frm_type.php" enctype="multipart/form-data" >
      <table width="100%" border="0" cellpadding="5" cellspacing="5">
        <tr>
          <td width="15%"><div align="right"><span style="font-weight: bold">Start : </span></div></td>
          <td width="28%"><input name="st_date" type="text" id="st_date" value="<? echo date("Y-m-d"); ?>"/>     </td>
  <td width="17%">&nbsp;</td>
  <td width="40"></td>
        </tr>
        <tr>
          <td colspan="4" align="center">
  <? $r=0; while($row  < count($type)){?>
<input type="submit" name="type_id" id="type_id" value="<?= $q_type[$r]["type_name"] ?> " />
<input type="hidden" name="type_id" id="type_id" value="<?= $q_type[$r]["type_id"] ?> " />
  <? $r++;} ?>
  </td>
          </tr>
      </table>
        </form>
คือต้องการส่งค่า type_id  ไปยังหน้าถัดไปด้วยอ่ะค่ะ แต่ตอนนี้ ส่งแล้ว มันไม่ไปค่ะ  ไม่ทราบว่า ผิดตรงไหนค่ะ

anatasia


test_one


talon

1. ค่าใน value ของ input hidden มันมีช่องว่างอยู่ครับ

2. ก่อน POST ลอง view source ดูก่อนครับ ว่าเป็นอย่างไร
[direct=http://www.ทัวร์แชงกรีล่า.com]ทัวร์แชงกรีล่า[/direct] [direct=http://www.จิ่วจ้ายโกว.com]จิ่วจ้ายโกว[/direct] [direct=http://www.เที่ยวกระบี่.net]กระบี่[/direct] [direct=http://www.แชงกรีล่า.com]แชงกรีล่า[/direct]

test_one

อ้างถึงจาก: talon ใน 26 มกราคม 2012, 04:17:03
1. ค่าใน value ของ input hidden มันมีช่องว่างอยู่ครับ

2. ก่อน POST ลอง view source ดูก่อนครับ ว่าเป็นอย่างไร

1. ลองแล้วก็ไม่ได้ค่ะ
2. ลอง echo  ออกมาดู  type_id  ก็ออกมาเป็น type_id  ค่ะ  แต่เวลาส่งค่า ค่าที่ส่งไปนั้น ส่งแต่ค่าที่ 1 ค่ะ  ไม่ทราบว่า วิธีการส่ง ผิดหรือป่าวค่ะ

MeenyFancy

#5
จากนี้

<input type="submit" name="type_id" id="type_id" value="<?= $q_type[$r]["type_name"] ?> " />
<input type="hidden" name="type_id" id="type_id" value="<?= $q_type[$r]["type_id"] ?> " />


แก้ตามนี้

<input type="submit" name="type_name" id="type_name" value="<?= $q_type[$r]["type_name"] ?> " />
<input type="hidden" name="type_id" id="type_id" value="<?= $q_type[$r]["type_id"] ?> " />
Have a good trip.
[direct=http://petdeecare.com]สุนัขป่วย[/direct] [direct=http://petdeecare.com]แมวป่วย[/direct]
[direct=http://petdeecare.com]หนูป่วย[/direct] [direct=http://petdeecare.com]อาหารแมว[/direct] [direct=http://petdeecare.com]อาหารหมา[/direct]

talon


value="<?= $q_type[$r]["type_id"] ?> " />

ลองสังเกตุดูนะครับ ค่า value หลัง php tag มันมีช่องว่างอยู่ ซึ่งอาจทำให้เกิด error
ลองแก้ตามนี้ครับ

<input type="submit" name="type_name" id="type_name" value="<?= $q_type[$r]["type_name"] ?>" />
<input type="hidden" name="type_id" id="type_id" value="<?= $q_type[$r]["type_id"] ?>" />
[direct=http://www.ทัวร์แชงกรีล่า.com]ทัวร์แชงกรีล่า[/direct] [direct=http://www.จิ่วจ้ายโกว.com]จิ่วจ้ายโกว[/direct] [direct=http://www.เที่ยวกระบี่.net]กระบี่[/direct] [direct=http://www.แชงกรีล่า.com]แชงกรีล่า[/direct]

test_one

อ้างถึงจาก: MeenyFancy ใน 26 มกราคม 2012, 10:29:38
จากนี้

<input type="submit" name="type_id" id="type_id" value="<?= $q_type[$r]["type_name"] ?> " />
<input type="hidden" name="type_id" id="type_id" value="<?= $q_type[$r]["type_id"] ?> " />


แก้ตามนี้

<input type="submit" name="type_name" id="type_name" value="<?= $q_type[$r]["type_name"] ?> " />
<input type="hidden" name="type_id" id="type_id" value="<?= $q_type[$r]["type_id"] ?> " />


ลองทำแล้ว ไม่ได้ ค่ะ รบกวน ชาวย ดูให้หน่อยนะค่ะ งง มากเลยค่ะ

MeenyFancy

ถ้างั้นขอ code ฝั่งรับด้วยครับ
Have a good trip.
[direct=http://petdeecare.com]สุนัขป่วย[/direct] [direct=http://petdeecare.com]แมวป่วย[/direct]
[direct=http://petdeecare.com]หนูป่วย[/direct] [direct=http://petdeecare.com]อาหารแมว[/direct] [direct=http://petdeecare.com]อาหารหมา[/direct]

test_one

อ้างถึงจาก: talon ใน 26 มกราคม 2012, 10:34:04

value="<?= $q_type[$r]["type_id"] ?> " />

ลองสังเกตุดูนะครับ ค่า value หลัง php tag มันมีช่องว่างอยู่ ซึ่งอาจทำให้เกิด error
ลองแก้ตามนี้ครับ

<input type="submit" name="type_name" id="type_name" value="<?= $q_type[$r]["type_name"] ?>" />
<input type="hidden" name="type_id" id="type_id" value="<?= $q_type[$r]["type_id"] ?>" />


<input type="hidden" name="type_id" id="type_id" value="<?=$q_type[$r]["type_id"];?>"/>   แก้แบบนี้ก็ยังไม่ได้ ค่ะ

test_one

อ้างถึงจาก: MeenyFancy ใน 26 มกราคม 2012, 10:40:37
ถ้างั้นขอ code ฝั่งรับด้วยครับ

if($_POST["type_id"] != ""){
   echo $type_id = $_POST["type_id"];
}

MeenyFancy

ไม่ต้องละ ผมรู้แระ  มันอยู่ที่ quote
แก้ตามนี้ครับ

<input type="submit" name="type_name" id="type_name" value='<?= $q_type[$r]["type_name"]?>' />
<input type="hidden" name="type_id" id="type_id" value='<?= $q_type[$r]["type_id"] ?>' />

Have a good trip.
[direct=http://petdeecare.com]สุนัขป่วย[/direct] [direct=http://petdeecare.com]แมวป่วย[/direct]
[direct=http://petdeecare.com]หนูป่วย[/direct] [direct=http://petdeecare.com]อาหารแมว[/direct] [direct=http://petdeecare.com]อาหารหมา[/direct]

test_one

อ้างถึงจาก: MeenyFancy ใน 26 มกราคม 2012, 10:44:55
ไม่ต้องละ ผมรู้แระ  มันอยู่ที่ quote
แก้ตามนี้ครับ

<input type="submit" name="type_name" id="type_name" value='<?= $q_type[$r]["type_name"]?>' />
<input type="hidden" name="type_id" id="type_id" value='<?= $q_type[$r]["type_id"] ?>' />



<input type="submit" name="type_name" id="type_name" value='<?=$q_type[$r]["type_name"];?>'/>
<input type="hidden" name="type_id" id="type_id" value='<?=$q_type[$r]["type_id"];?>'/> 

ไม่ได้ ค่ะ  งง แหละเนี้ย

sleepcat

ลองลบ
enctype="multipart/form-data"
ออกครับ

MeenyFancy

ถามหน่อยครับ

while($row  < count($type)){?>
<input type="submit" name="type_name" id="type_name" value='<?= $q_type[$r]["type_name"]?>' />
<input type="hidden" name="type_id" id="type_id" value='<?= $q_type[$r]["type_id"] ?>' />
 <? $r++;} ?>

มันคือการโชว์ type id มาหลายๆ อัน ตาม data ที่get มาได้แม่นบ่
แล้วคุณจะ กด submit ตามนั้น ใช่มั้ย
ถ้าใช่ ก็เอวังครับ มันจะส่งกลับแต่ค่าแรกที่เขียน

ถ้าไม่ใช่ รบกวนเอาหน้าบ่นเว็บ view source มาให้ดูหน่อย
Have a good trip.
[direct=http://petdeecare.com]สุนัขป่วย[/direct] [direct=http://petdeecare.com]แมวป่วย[/direct]
[direct=http://petdeecare.com]หนูป่วย[/direct] [direct=http://petdeecare.com]อาหารแมว[/direct] [direct=http://petdeecare.com]อาหารหมา[/direct]

talon

ลอง view source ใน browser รึยังครับว่าค่า value มันเป็นค่าอะไร
ถ้าค่าใน value เป็น ""
น่าจะเกิดความสับสนเรื่องชื่อตัวแปร array $type กับ $q_type น่ะครับ
[direct=http://www.ทัวร์แชงกรีล่า.com]ทัวร์แชงกรีล่า[/direct] [direct=http://www.จิ่วจ้ายโกว.com]จิ่วจ้ายโกว[/direct] [direct=http://www.เที่ยวกระบี่.net]กระบี่[/direct] [direct=http://www.แชงกรีล่า.com]แชงกรีล่า[/direct]

test_one

อ้างถึงจาก: MeenyFancy ใน 26 มกราคม 2012, 11:03:28
ถามหน่อยครับ

while($row  < count($type)){?>
<input type="submit" name="type_name" id="type_name" value='<?= $q_type[$r]["type_name"]?>' />
<input type="hidden" name="type_id" id="type_id" value='<?= $q_type[$r]["type_id"] ?>' />
 <? $r++;} ?>

มันคือการโชว์ type id มาหลายๆ อัน ตาม data ที่get มาได้แม่นบ่
แล้วคุณจะ กด submit ตามนั้น ใช่มั้ย
ถ้าใช่ ก็เอวังครับ มันจะส่งกลับแต่ค่าแรกที่เขียน

ถ้าไม่ใช่ รบกวนเอาหน้าบ่นเว็บ view source มาให้ดูหน่อย

ช่าย ค่ะ  คือ การ วน loop  ค่า type_id  แล้ว ส่งค่า ค่ะ  แล้วแบบนี้ค้องทำไง ค่ะ

MeenyFancy

อ้างถึงจาก: test_one ใน 26 มกราคม 2012, 11:07:58
ช่าย ค่ะ  คือ การ วน loop  ค่า type_id  แล้ว ส่งค่า ค่ะ  แล้วแบบนี้ค้องทำไง ค่ะ

จะวนลูปมาโชว์ แล้วเลือก id อันไดอันนึง ทำไมไม่ใช้ radio button ละคับ
Have a good trip.
[direct=http://petdeecare.com]สุนัขป่วย[/direct] [direct=http://petdeecare.com]แมวป่วย[/direct]
[direct=http://petdeecare.com]หนูป่วย[/direct] [direct=http://petdeecare.com]อาหารแมว[/direct] [direct=http://petdeecare.com]อาหารหมา[/direct]

talon

ลองเปลี่ยน $q_type[$r]["type_id"] เป็น $type[$r]["type_id"] ดูนะครับ

(ไม่รู้ที่มาที่ไปของ $type กับ $q_type หรอกครับ เดาจาก code เอา )
[direct=http://www.ทัวร์แชงกรีล่า.com]ทัวร์แชงกรีล่า[/direct] [direct=http://www.จิ่วจ้ายโกว.com]จิ่วจ้ายโกว[/direct] [direct=http://www.เที่ยวกระบี่.net]กระบี่[/direct] [direct=http://www.แชงกรีล่า.com]แชงกรีล่า[/direct]

talon

อ้างถึงจาก: MeenyFancy ใน 26 มกราคม 2012, 11:12:34

จะวนลูปมาโชว์ แล้วเลือก id อันไดอันนึง ทำไมไม่ใช้ radio button ละคับ


ถูกต้องแล้วครับ หรือใช้ dropdown listbox ก็ได้
[direct=http://www.ทัวร์แชงกรีล่า.com]ทัวร์แชงกรีล่า[/direct] [direct=http://www.จิ่วจ้ายโกว.com]จิ่วจ้ายโกว[/direct] [direct=http://www.เที่ยวกระบี่.net]กระบี่[/direct] [direct=http://www.แชงกรีล่า.com]แชงกรีล่า[/direct]