mysql - How to create a numbered list inside a table with PHP -


i'm executing type of code inside table.

while($row = mysql_fetch_array($result))   {  echo "" . $row['id'] . "";  echo "" . $row['name'] . "";  echo "" . $row['car'] . "";   } 

which works great , gives me numbered list (1 mike volvo, 2 mike ford) example. problem have multiple users in same table there gaps in list else's entry since i'm using auto incremented id numbers.

so assuming have 5 entries want 1-5 right 5-30-45-65 or whatever.

anyway looked around solution , found $number = 1; $number++; effective , kind of works , gives me 1-5 list independent of whatever id's are.

the problem when reverse list using order xxx desc last entry becomes 1 , first entry becomes 5. want first entry remain 1 , last entry 5.

do have ideas on how create function using php?

you need simple user $number mentioned in following code

 $number = 1;  while($row = mysql_fetch_array($result))  {     echo $number;     echo "" . $row['name'] . "";     echo "" . $row['car'] . "";     ++$number;  } 

even if in sql have order by not matter in case.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -