Hi there :-)
I was just wondering, is there a way that I can give each row returned from a database query an ID ascending from 1 so that it doesn't use the row id from the database?
i.e. I have a table:-
id
username
email
password
The rows are:-
1 | XxX | email@email.com | password
2 | Test | test@email.com | password2
3 | Boo | boo@gmail.com | password3
4 | Boot | boot@hotmail.com | password4
Now say I did a query:-
mysql_query("SELECT * FROM table WHERE username LIKE '%boo%'");
This would return the array for the rows and the id's would be 3 and 4.
But the result id would be 1 and 2... is there any way I can display the result id instead of the row ids? Do I just do a counter with in the while loop?
$query = mysql_query("SELECT * FROM table WHERE username LIKE '%boo%'");
$id=0;
while ($row = mysql_fetch_array($query)) {
$id=$id+1;
echo("$id. $row[username] | $row[email]<br>");
}
Would it just be a simple case of something like that?