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); ?> Link to comment https://forums.phpfreaks.com/topic/172328-want-one-result-per-line/ 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 Link to comment https://forums.phpfreaks.com/topic/172328-want-one-result-per-line/#findComment-908603 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); ?> Link to comment https://forums.phpfreaks.com/topic/172328-want-one-result-per-line/#findComment-908608 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 />"); Link to comment https://forums.phpfreaks.com/topic/172328-want-one-result-per-line/#findComment-908615 Share on other sites More sharing options...
webguync Posted August 28, 2009 Author Share Posted August 28, 2009 got it. thanks! Link to comment https://forums.phpfreaks.com/topic/172328-want-one-result-per-line/#findComment-908618 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 Link to comment https://forums.phpfreaks.com/topic/172328-want-one-result-per-line/#findComment-908622 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.