manalnor Posted April 5, 2010 Share Posted April 5, 2010 Hello friends, if i've stored lins in database like this line x line y line z so it called from database as $lines then is there something called auto numbering function where is numbering the lines 1- line x 2- line y 3- line z (something)$lines and please don't say why not using $id of each line cause when i delete the any of the lines for example the second line then it will be 1- line x 3- line z and i wanna show it as 1- line x 2- line z so auto numbering not id ? so is there any function or order by command thanks Link to comment https://forums.phpfreaks.com/topic/197694-auto-numbering/ Share on other sites More sharing options...
Pikachu2000 Posted April 6, 2010 Share Posted April 6, 2010 Set a variable to integer 1, then echo and increment it in the while statement. $i = 1; while( $array = mysqli_fetch_assoc($result) { echo $i . " - " . $array['index']; $i ++; } Link to comment https://forums.phpfreaks.com/topic/197694-auto-numbering/#findComment-1037490 Share on other sites More sharing options...
manalnor Posted April 6, 2010 Author Share Posted April 6, 2010 it works fine , thanks so much now one last question if i wanna make it shown as number -1 for same example 1- line x 2- line y 3- line z i wanna make it -1 after 1 so 1- line x 1- line y (2-1=1) 2- line z ( 3-1=2) hope you've got the idea thanks in advance Link to comment https://forums.phpfreaks.com/topic/197694-auto-numbering/#findComment-1037518 Share on other sites More sharing options...
manalnor Posted April 6, 2010 Author Share Posted April 6, 2010 thanks very much, solved i made $i = 0 also i've tired -1 it is very nice code thanks alot Link to comment https://forums.phpfreaks.com/topic/197694-auto-numbering/#findComment-1037520 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.