illuz1on Posted April 15, 2007 Share Posted April 15, 2007 // Short vars $id = $record['id']; $title = $record['title']; echo "$id. $title"; } ?> This is just a snippet of code how do I make the echo line put each entry on a new line WHILE being in a while loop? Thanks alot Quote Link to comment https://forums.phpfreaks.com/topic/47135-new-line-while-in-while-loop/ Share on other sites More sharing options...
ignace Posted April 15, 2007 Share Posted April 15, 2007 just use backward slash followed by an n (newline) between double quotes <?php echo "$id \n $title"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/47135-new-line-while-in-while-loop/#findComment-229845 Share on other sites More sharing options...
Lumio Posted April 15, 2007 Share Posted April 15, 2007 but to display it as a new line, use <br />: echo "$id <br />\n $title"; Quote Link to comment https://forums.phpfreaks.com/topic/47135-new-line-while-in-while-loop/#findComment-229847 Share on other sites More sharing options...
anthylon Posted April 15, 2007 Share Posted April 15, 2007 Okay, if $row is your result from mysql_query, than you could do this: $result= mysql_query(your_query_string_here); while ($row = mysql_fetch_assoc($result)) { echo $row['id'] . ' ' .$row['title'] .'<br>'; } - id and title are field from your db table. - < br > (without spaces) is new line in HTML I hope this was what you asked us for. Quote Link to comment https://forums.phpfreaks.com/topic/47135-new-line-while-in-while-loop/#findComment-229848 Share on other sites More sharing options...
illuz1on Posted April 15, 2007 Author Share Posted April 15, 2007 Thanks yeah used lumino's option.. What if i wanted to add a bracket with (Edit/Delete) in it, linking to edit.php and delete.php? Thanks alot guys Quote Link to comment https://forums.phpfreaks.com/topic/47135-new-line-while-in-while-loop/#findComment-229853 Share on other sites More sharing options...
anthylon Posted April 15, 2007 Share Posted April 15, 2007 Well independent. If you want use form, than make form fields. But if you want use link than you can make like this: $result= mysql_query(your_query_string_here); while ($row = mysql_fetch_assoc($result)) { echo "${row['id']} ${row['title']} <a href='delete.php?id=${row['id']}'>Delete</a>"; } In delete.php use $id =$_GET['id'] so you'll get id from link. But, be careful and check if user has been logged or not because somebody could use it to delte more than you want. Also I'm always making some checking to exclude possibility of error (first step would be to check if ID is numeric), etc... Quote Link to comment https://forums.phpfreaks.com/topic/47135-new-line-while-in-while-loop/#findComment-229865 Share on other sites More sharing options...
boo_lolly Posted April 15, 2007 Share Posted April 15, 2007 // Short vars $id = $record['id']; $title = $record['title']; echo "$id. $title"; } ?> This is just a snippet of code how do I make the echo line put each entry on a new line WHILE being in a while loop? Thanks alot what the hell are you talking about? Quote Link to comment https://forums.phpfreaks.com/topic/47135-new-line-while-in-while-loop/#findComment-229866 Share on other sites More sharing options...
Lumio Posted April 16, 2007 Share Posted April 16, 2007 I think everyone understands him and also exact you Quote Link to comment https://forums.phpfreaks.com/topic/47135-new-line-while-in-while-loop/#findComment-230480 Share on other sites More sharing options...
per1os Posted April 16, 2007 Share Posted April 16, 2007 // Short vars $id = $record['id']; $title = $record['title']; echo "$id. $title"; } ?> This is just a snippet of code how do I make the echo line put each entry on a new line WHILE being in a while loop? Thanks alot what the hell are you talking about? What the hell are you talking about? lol I think he made is case very clear, and obviously so as he got his questioned answer by 2 people =) Quote Link to comment https://forums.phpfreaks.com/topic/47135-new-line-while-in-while-loop/#findComment-230485 Share on other sites More sharing options...
boo_lolly Posted April 16, 2007 Share Posted April 16, 2007 people should learn to be articulate. that's all i'm saying. Quote Link to comment https://forums.phpfreaks.com/topic/47135-new-line-while-in-while-loop/#findComment-230512 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.