dubc07 Posted April 26, 2009 Share Posted April 26, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/155730-number-each-query-pulled-from-database/ Share on other sites More sharing options...
.josh Posted April 26, 2009 Share Posted April 26, 2009 so..you know how to pull data from a database and display it but you can't figure out how to make a simple counting variable? $count = 1; while (...) { echo $count; $count++; } Quote Link to comment https://forums.phpfreaks.com/topic/155730-number-each-query-pulled-from-database/#findComment-819695 Share on other sites More sharing options...
dubc07 Posted April 26, 2009 Author Share Posted April 26, 2009 i know how to pull a total count, but not to denote each query and echo. Still kinda new to php. Thanks for your response. Quote Link to comment https://forums.phpfreaks.com/topic/155730-number-each-query-pulled-from-database/#findComment-819698 Share on other sites More sharing options...
premiso Posted April 26, 2009 Share Posted April 26, 2009 $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... Quote Link to comment https://forums.phpfreaks.com/topic/155730-number-each-query-pulled-from-database/#findComment-819921 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.