roldahayes Posted November 23, 2012 Share Posted November 23, 2012 Hi, This code returns 2 table fields. "code" then "name" all works well until 2 or more rows are retuned and then it displays in one long line.... How can I get it to display each line separately? $message .= $row['code'] ." - ". $row["name"]; Link to comment https://forums.phpfreaks.com/topic/271067-how-to-display-this-data-in-rows/ Share on other sites More sharing options...
White_Lily Posted November 23, 2012 Share Posted November 23, 2012 Post the code for the whole loop and then we can help you properly. Link to comment https://forums.phpfreaks.com/topic/271067-how-to-display-this-data-in-rows/#findComment-1394590 Share on other sites More sharing options...
roldahayes Posted November 23, 2012 Author Share Posted November 23, 2012 if(mysql_num_rows($result) >= 1) { $email = '[email protected]'; $subject = "LOW STOCK WARNING!"; $message = "One or more products are running low:\r\n\r\n"; while($row = mysql_fetch_assoc($result)) { $message .= $row['code'] ." - ". $row["name"]; } if(mail($email, $subject, $message)) { //mail successfully sent } else { //mail unsuccessful } } Link to comment https://forums.phpfreaks.com/topic/271067-how-to-display-this-data-in-rows/#findComment-1394591 Share on other sites More sharing options...
Christian F. Posted November 23, 2012 Share Posted November 23, 2012 Add a newline ("\n") to the end of the string, inside the loop. Link to comment https://forums.phpfreaks.com/topic/271067-how-to-display-this-data-in-rows/#findComment-1394592 Share on other sites More sharing options...
roldahayes Posted November 23, 2012 Author Share Posted November 23, 2012 Thanks I see where I was going wrong, I've fixed it with: $message .= $row['code'] ." - ". $row["name"]."\n"; Link to comment https://forums.phpfreaks.com/topic/271067-how-to-display-this-data-in-rows/#findComment-1394647 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.