次のような値を持つデータベースを持っています
- マンゴー
- りんご
- オレンジ
そして今、これらの値を html テーブルに個別に表示したいと考えています。最初の行はマンゴーのみで、次のボタン、リンゴ、次のボタン、オレンジの順にクリックします。
次のような値を持つデータベースを持っています
そして今、これらの値を html テーブルに個別に表示したいと考えています。最初の行はマンゴーのみで、次のボタン、リンゴ、次のボタン、オレンジの順にクリックします。
のような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+"]; ?>";
}