|
 |
|
การเรียก array มาแสดง ใน option ครับ ทำไม่ได้สักที งง มากๆ |
|
 |
|
|
 |
 |
|
คุณ echo $i ออกมานิ ค่าในoptionจึงเป็น 0กับ1
คุณต้อง echo $extend
|
 |
 |
 |
 |
Date :
2009-04-07 08:52:09 |
By :
mai_sao |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
<?php
$extend = array("1"=>"เปรี้ยวๆ", "2"=>"หวานๆ"); //ใช้แค่มิติเดียวก็พอ
foreach($extend as $index => $taste){
echo "<option value=\"" . $index . "\">" . $taste . "</option>";
}
?>
|
 |
 |
 |
 |
Date :
2009-04-07 12:34:11 |
By :
plakrim |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
<?php
$extend = array("1"=>"เปรี้ยวๆ", "2"=>"หวานๆ");
?>
<select name="select" id="select">
<?php
$i=1;
while($i <=count($extend))
foreach($extend as $index => $taste){
?>
<option value="<? echo "$index" ?>"><? echo "$taste";?> </option>
<?php
$i++; }
?>
</select>
ปล.ดัดแปลงมาจากคุณ PlaKriM
|
 |
 |
 |
 |
Date :
2009-04-07 14:38:06 |
By :
mai_sao |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แนะนำนะครับอะไรที่เป็น Array เวลาให้แสดงค่าออกมา
แนะนำให้เป็น
Foreach(){
}
ตัวนี้นะลองดูนะ ง่ายกว่าเยอะ
|
 |
 |
 |
 |
Date :
2009-04-07 16:06:52 |
By :
dr.website |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เยี่ยม ครับ ขอบคุณมากนะ ท่านๆ ทั้งหลาย
|
 |
 |
 |
 |
Date :
2009-04-08 20:15:15 |
By :
dang |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|