webguync Posted August 28, 2009 Share Posted August 28, 2009 I am trying to get my results to print one per line, but what I have isn't working. <?php $result = mysql_query("SELECT incorrect_resp FROM TableName"); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { printf("Incorrect response %s", $row["incorrect_resp"],"\n"); } mysql_free_result($result); ?> Quote Link to comment Share on other sites More sharing options...
Maq Posted August 28, 2009 Share Posted August 28, 2009 If you're displaying to the browser use not \n Quote Link to comment Share on other sites More sharing options...
webguync Posted August 28, 2009 Author Share Posted August 28, 2009 thanks, I tried this though and it didn't work. <?php $result = mysql_query("SELECT incorrect_resp FROM TableName"); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { printf("Incorrect response %s", $row["incorrect_resp"],"<br />"); } mysql_free_result($result); ?> Quote Link to comment Share on other sites More sharing options...
lemmin Posted August 28, 2009 Share Posted August 28, 2009 Make that last comma a period: printf("Incorrect response %s", $row["incorrect_resp"]."<br />"); Quote Link to comment Share on other sites More sharing options...
webguync Posted August 28, 2009 Author Share Posted August 28, 2009 got it. thanks! Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted August 28, 2009 Share Posted August 28, 2009 Make that last comma a period: printf("Incorrect response %s", $row["incorrect_resp"]."<br />"); It should actually be printf("Incorrect response %s<br />", $row["incorrect_resp"]); As per the manual on printf 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.