franzwarning Posted March 9, 2011 Share Posted March 9, 2011 Is there any way that I can get mysql_fetch_assoc only to run once? Here is my code: $query = mysql_query("SELECT * FROM items ORDER BY id DESC"); while ($row = mysql_fetch_assoc($query)) { $id = $row['id']; } Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted March 9, 2011 Share Posted March 9, 2011 Don't put in a while loop <?php $query = mysql_query("SELECT * FROM items ORDER BY id DESC"); if (mysql_numrows($query) > 0) { $row = mysql_fetch_assoc($query); $id = $row['id']; } ?> Ken Quote Link to comment Share on other sites More sharing options...
franzwarning Posted March 9, 2011 Author Share Posted March 9, 2011 Guess I never thought of that.... thanks! Quote Link to comment 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.