Serial number in PHP
Please I am building a table in php that will list item from database, the amount listed depends on amount available. I want to number my s/n column serially using php. eg.
s/n Name amoun开发者_StackOverflowt
1 Mathew $12
2
3
4
etc
Try MYSQL's auto increment. So the first user who registers gets SN 1 and second would get 2 etc
http://dev.mysql.com/doc/refman/5.0/en/example-auto-increment.html
see range()
<?php
// array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)
foreach (range(0, 12) as $number) {
echo $number;
}
精彩评论