Вопрос

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