Jump to content

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...

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.