I am fetching data from MySQL database... I want to check index of each row... e.g
while($row=mysql_fetch_array($result)
{
i want index of $row in each row... (current Index).
}
Please Help me. Thanks
If you want the index from the database:
<?php
...
$result = mysql_query("SELECT * FROM whatever");
while($row = mysql_fetch_array($result)) {
echo $row['index'];
# Where index is the field name containing the item ID from your database
}
...
?>
Or, if you want to count the number of items based on the output:
<?php
..
$result = mysql_query("SELECT * FROM whatever");
$index = 0;
while($row = mysql_fetch_array($result)) {
echo $index.' '.$row['whatever'];
$index++;
}
..
?>
That's what I understood from your question..
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With