Jump to content

Number each query pulled from database


dubc07

Recommended Posts

So i wanting a code that will pull a certain query and then number each pull.

 

The echo output would look like this.

 

1 row

2 row

3 row

4 row

 

This would not be based on the id of the table.

Just a count function that doesn't give just the total but denote each with a number.

Link to comment
https://forums.phpfreaks.com/topic/155730-number-each-query-pulled-from-database/
Share on other sites

$sql = "SELECT * FROM sometable WHERE some='condition'";
$result = mysql_query($sql) or die("SQL WAS: {$sql}<br />ERROR WAS: " . mysql_error());

$i=1;
while ($row = mysql_fetch_assoc($result)) {
    echo "{$i} row: " . print_r($row, 1) . "<br />"; // note this can be changed to display certain output.
    $i++;
}

 

Since you failed to provide any type of code, this is the best I can give you. Hopefully that will at least get you started. If this is not what you want, perhaps post some code that you have already tried...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.