문제

I am working on PHP using Kohana 3.2.I am displaying large number of data from database.I want to set the serial no from 1,2 upto the n-numbers depend on the number of data i am showing.I want to show the data in sequence.How to handle it through program.I can echo the total number of data(count) in page.

I don't know how to handle it in program.Need help.

도움이 되었습니까?

해결책

Well, it depends on whether you want to save the number or not, I guess.

If you do want to save it, create a field that will store the number and use AUTO_INCREMENT, read about it here.

If you don't need it to be stored, well, just echo a variable that increases itself. Something like this.

$i = 0;
foreach($data as $value){
   echo $i . ": " . $value;
   $i++; 
}

Mind, this is just a simple, basic code to give you an idea on how to do it.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top