PHPスクリプトで助けが必要です。この選択フィールドでSQLテーブルのIDのNAMEを検索し、PHP経由でエコー
foreach構文は、1つのオプションフィールドを埋め:
<select name="table_id[]">
<option value="">---</option>
<?php
foreach ($tpl['table_arr'] as $table)
{
?>
<option value="<?php echo $table['id']; ?>"<?php echo isset($_GET['table_id']) ? ($_GET['table_id'] == $table['id'] ? ' selected="selected"' : null) : null;?>>
<?php echo stripslashes($table['name']); ?>, <?php echo $table['seats'] . ' ' . ($table['seats'] > 1 ? __('lblPeople', true, false) : __('lblPerson', true, false)); ?>
</option>
<?php
}
?>
['table_id'] == $table['id']
「を選択」された場合には、単一のオプションフィールドとハイライトの中にすべてのテーブルの$table['name']
と$table['seats']
をエコーします。
「選択された」テーブルNAMEのみをオプション付きの選択可能なフィールドにラップすることなくエコーすることは可能ですか?
foreach構文なしの単一IDは
<?php echo $_GET['table_id']; ?>
を経由して表示することができますが、私は、このIDの名前を取得できますか?
事前に感謝します!
これが出力されます:
こんにちはMawia、
これは私が正しくあなたの質問を理解していれば、空白の配列開け出力
Array (
[0] => Array ([id] => 2 [room_id] => 1 [width] => 280 [height] => 70 [top] => 43 [left] => 71 [name] => 11 [seats] => 8 [minimum] => 6 [ratio] => 4x1 [round_table] => 0 [turned_table] => none)
[1] => Array ([id] => 15 [room_id] => 1 [width] => 210 [height] => 70 [top] => 141 [left] => 71 [name] => 12 [seats] => 6 [minimum] => 4 [ratio] => [round_table] => 0 [turned_table] => none)
[2] => Array ([id] => 16 [room_id] => 1 [width] => 140 [height] => 70 [top] => 138 [left] => 439 [name] => 13 [seats] => 4 [minimum] => 2 [ratio] => [round_table] => 0 [turned_table] => none)
[3] => Array ([id] => 17 [room_id] => 1 [width] => 140 [height] => 70 [top] => 139 [left] => 655 [name] => 14 [seats] => 4 [minimum] => 2 [ratio] => [round_table] => 0 [turned_table] => none)
[4] => Array ([id] => 18 [room_id] => 1 [width] => 140 [height] => 70 [top] => 256 [left] => 442 [name] => 15 [seats] => 4 [minimum] => 2 [ratio] => [round_table] => 0 [turned_table] => none)
[5] => Array ([id] => 19 [room_id] => 1 [width] => 140 [height] => 70 [top] => 256 [left] => 653 [name] => 16 [seats] => 4 [minimum] => 2 [ratio] => [round_table] => 0 [turned_table] => none)
[6] => Array ([id] => 20 [room_id] => 1 [width] => 140 [height] => 70 [top] => 380 [left] => 443 [name] => 17 [seats] => 4 [minimum] => 2 [ratio] => [round_table] => 0 [turned_table] => none)
[7] => Array ([id] => 21 [room_id] => 1 [width] => 210 [height] => 70 [top] => 255 [left] => 77 [name] => 18 [seats] => 6 [minimum] => 4 [ratio] => [round_table] => 0 [turned_table] => none)
[8] => Array ([id] => 22 [room_id] => 1 [width] => 210 [height] => 70 [top] => 366 [left] => 77 [name] => 19 [seats] => 6 [minimum] => 4 [ratio] => [round_table] => 0 [turned_table] => none)
[9] => Array ([id] => 23 [room_id] => 1 [width] => 420 [height] => 70 [top] => 43 [left] => 404 [name] => 20 [seats] => 12 [minimum] => 8 [ratio] => [round_table] => 0 [turned_table] => none)
[10] => Array ([id] => 24 [room_id] => 1 [width] => 210 [height] => 70 [top] => 42 [left] => 875 [name] => 21 [seats] => 6 [minimum] => 3 [ratio] => [round_table] => 0 [turned_table] => none)
[11] => Array ([id] => 25 [room_id] => 1 [width] => 210 [height] => 70 [top] => 139 [left] => 876 [name] => 22 [seats] => 6 [minimum] => 3 [ratio] => [round_table] => 0 [turned_table] => none)
[12] => Array ([id] => 26 [room_id] => 1 [width] => 140 [height] => 70 [top] => 379 [left] => 650 [name] => 23 [seats] => 4 [minimum] => 2 [ratio] => [round_table] => 0 [turned_table] => none)
[13] => Array ([id] => 35 [room_id] => 2 [width] => 70 [height] => 210 [top] => 53 [left] => 109 [name] => 1 [seats] => 6 [minimum] => 3 [ratio] => 1x3 [round_table] => 0 [turned_table] => left)
[14] => Array ([id] => 36 [room_id] => 2 [width] => 140 [height] => 70 [top] => 53 [left] => 418 [name] => 2 [seats] => 4 [minimum] => 2 [ratio] => [round_table] => 0 [turned_table] => none)
[15] => Array ([id] => 37 [room_id] => 2 [width] => 140 [height] => 70 [top] => 162 [left] => 419 [name] => 3 [seats] => 4 [minimum] => 2 [ratio] => [round_table] => 0 [turned_table] => none)
[16] => Array ([id] => 38 [room_id] => 2 [width] => 210 [height] => 70 [top] => 163 [left] => 105 [name] => 4 [seats] => 6 [minimum] => 3 [ratio] => [round_table] => 0 [turned_table] => none)
[17] => Array ([id] => 39 [room_id] => 2 [width] => 70 [height] => 70 [top] => 288 [left] => 613 [name] => 5 [seats] => 2 [minimum] => 1 [ratio] => [round_table] => 0 [turned_table] => none)
[18] => Array ([id] => 40 [room_id] => 2 [width] => 140 [height] => 70 [top] => 290 [left] => 419 [name] => 6 [seats] => 4 [minimum] => 2 [ratio] => [round_table] => 0 [turned_table] => none)
[19] => Array ([id] => 41 [room_id] => 2 [width] => 210 [height] => 70 [top] => 293 [left] => 107 [name] => 7 [seats] => 6 [minimum] => 4 [ratio] => [round_table] => 0 [turned_table] => none)
[20] => Array ([id] => 42 [room_id] => 2 [width] => 140 [height] => 70 [top] => 421 [left] => 147 [name] => 8 [seats] => 4 [minimum] => 2 [ratio] => [round_table] => 0 [turned_table] => none)
[21] => Array ([id] => 53 [room_id] => 3 [width] => 140 [height] => 140 [top] => 33 [left] => 488 [name] => 220 [seats] => 12 [minimum] => 8 [ratio] => 1x6 [round_table] => 1 [turned_table] => none)
[22] => Array ([id] => 54 [room_id] => 3 [width] => 350 [height] => 70 [top] => 36 [left] => 48 [name] => 221 [seats] => 10 [minimum] => 6 [ratio] => [round_table] => 0 [turned_table] => none)
[23] => Array ([id] => 55 [room_id] => 3 [width] => 140 [height] => 70 [top] => 131 [left] => 43 [name] => 222 [seats] => 4 [minimum] => 3 [ratio] => [round_table] => 0 [turned_table] => none)
[24] => Array ([id] => 56 [room_id] => 3 [width] => 70 [height] => 70 [top] => 128 [left] => 210 [name] => 2220 [seats] => 2 [minimum] => 1 [ratio] => [round_table] => 0 [turned_table] => none)
[25] => Array ([id] => 57 [room_id] => 3 [width] => 140 [height] => 70 [top] => 222 [left] => 43 [name] => 223 [seats] => 4 [minimum] => 2 [ratio] => [round_table] => 0 [turned_table] => none)
[26] => Array ([id] => 58 [room_id] => 3 [width] => 70 [height] => 70 [top] => 222 [left] => 208 [name] => 2230 [seats] => 2 [minimum] => 1 [ratio] => [round_table] => 0 [turned_table] => none)
[27] => Array ([id] => 59 [room_id] => 3 [width] => 140 [height] => 70 [top] => 314 [left] => 45 [name] => 224 [seats] => 4 [minimum] => 2 [ratio] => [round_table] => 0 [turned_table] => none)
[28] => Array ([id] => 60 [room_id] => 3 [width] => 70 [height] => 70 [top] => 312 [left] => 206 [name] => 2240 [seats] => 2 [minimum] => 1 [ratio] => [round_table] => 0 [turned_table] => none)
[29] => Array ([id] => 61 [room_id] => 3 [width] => 140 [height] => 70 [top] => 418 [left] => 42 [name] => 225 [seats] => 4 [minimum] => 2 [ratio] => [round_table] => 0 [turned_table] => none)
[30] => Array ([id] => 62 [room_id] => 3 [width] => 70 [height] => 70 [top] => 418 [left] => 205 [name] => 2250 [seats] => 2 [minimum] => 1 [ratio] => [round_table] => 0 [turned_table] => none))
下記の私の答えを参照してください。
は、あなたの質問のデータによると、あなたは次のように提供idの名前を取得することができます。 –