0

次のような値を持つデータベースを持っています

  • マンゴー
  • りんご
  • オレンジ

そして今、これらの値を html テーブルに個別に表示したいと考えています。最初の行はマンゴーのみで、次のボタン、リンゴ、次のボタン、オレンジの順にクリックします。

4

1 に答える 1

0

のようなphp配列があるとします$array(0=>"mango",1=>"apple",2=>"oranges")

<table >
<tr>
<td id="myTable">
<?php echo $array[0]; ?>
</td>
</tr>
<script>var iterator = 0;</script>
<input type="button" value="next" onclick="nextVal(iterator)"/>

function nextVal(nextVal){
nextVal++;
document.getElementById("myTable").innerHTML = "<?php echo $array["+nextVal+"]; ?>";
}
于 2013-03-03T09:21:27.530 に答える