SamW Posted June 24, 2009 Share Posted June 24, 2009 Hi, I'm trying to get submit.php (after http://www.ballpointstudio.com/form2.php) to have a counter on each post, that increments each row. How can I do this within the code (or maybe in MySQL )? Thanks =D Link to comment https://forums.phpfreaks.com/topic/163463-solved-counter/ Share on other sites More sharing options...
SamW Posted June 24, 2009 Author Share Posted June 24, 2009 Oops, I forgot to add the actual code...silly me. <?php mysql_connect("localhost", "Censored", "Censored") or die(mysql_error()); mysql_select_db("runetyco_cms") or die(mysql_error()); $content = $_POST['content']; mysql_query("INSERT INTO cms (content) VALUES('$content' ) ") or die(mysql_error()); $result = mysql_query("SELECT * FROM cms") or die(mysql_error()); while ($row = mysql_fetch_array( $result )) { echo "<br /><br />Post: ".$row['content']; } ?> Link to comment https://forums.phpfreaks.com/topic/163463-solved-counter/#findComment-862490 Share on other sites More sharing options...
Adam Posted June 24, 2009 Share Posted June 24, 2009 You can do this very easily by just incrementing a variable on each loop: $i = 1; while ($row = mysql_fetch_array( $result )) { echo "<br /><br />Post " . $i . ": " . $row['content']; $i++; } Link to comment https://forums.phpfreaks.com/topic/163463-solved-counter/#findComment-862493 Share on other sites More sharing options...
SamW Posted June 24, 2009 Author Share Posted June 24, 2009 Thanks mate, you're a legend. Link to comment https://forums.phpfreaks.com/topic/163463-solved-counter/#findComment-862494 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.