Data seek function will display the table row result as an array.I used the same table progress for this tutorial too.
<?php $con = mysql_connect("localhost", "root", ""); if (!$con) { die('Could not connect: ' . mysql_error()); } $db_selected = mysql_select_db("my_database",$con); $sql = "SELECT * from progress"; $result = mysql_query($sql,$con); print_r(mysql_fetch_row($result)); echo "</br>"; mysql_data_seek($result,1); print_r(mysql_fetch_row($result)); echo "</br>"; mysql_data_seek($result,2); print_r(mysql_fetch_row($result)); echo "</br>"; mysql_data_seek($result,3); print_r(mysql_fetch_row($result)); echo "</br>"; mysql_data_seek($result,4); print_r(mysql_fetch_row($result)); echo "</br>"; mysql_data_seek($result,5); print_r(mysql_fetch_row($result)); echo "</br>"; mysql_data_seek($result,6); print_r(mysql_fetch_row($result)); echo "</br>"; mysql_data_seek($result,7); print_r(mysql_fetch_row($result)); echo "</br>"; mysql_data_seek($result,8); print_r(mysql_fetch_row($result)); echo "</br>"; mysql_data_seek($result,9); print_r(mysql_fetch_row($result)); echo "</br>"; mysql_data_seek($result,10); print_r(mysql_fetch_row($result)); echo "</br>"; mysql_data_seek($result,11); print_r(mysql_fetch_row($result)); mysql_close($con); ?> | Array
(
[0] => 1
[1] => January
[2] => 10
)
Array ( [0] => 2 [1] => February [2] => 20 ) Array ( [0] => 3 [1] => March [2] => 12 ) Array ( [0] => 4 [1] => April [2] => 21 ) Array ( [0] => 5 [1] => May [2] => 23 ) Array ( [0] => 6 [1] => June [2] => 21 ) Array ( [0] => 7 [1] => July [2] => 23 ) Array ( [0] => 8 [1] => August [2] => 27 ) Array ( [0] => 9 [1] => September [2] => 32 ) Array ( [0] => 10 [1] => October [2] => 14 ) Array ( [0] => 11 [1] => November [2] => 25 ) Array ( [0] => 12 [1] => December [2] => 24 ) |
No comments:
Post a Comment