xfezz Posted October 24, 2006 Share Posted October 24, 2006 the html source code generated from this block of code is one big long line of html code. (seems to scroll like 10 pages across, one div tag after another with the output of the database)[code] $SQL = "SELECT * FROM articles ORDER BY id DESC"; $result = mysql_query($SQL); while ($db_field = mysql_fetch_array($result)) { $now_format = $db_field['article_date']; $new_format = date('F d, Y',strtotime($now_format)); // transform echo "<div id=\"article_date\">". $new_format ."</div>"; // prints out: date in following format October 20, 2006 echo "<div id=\"article_chk\">"."<input type=\"checkbox\" name=\"del_select[]\" value=\"$db_field[id]\" />"."</div>"."<br>"; $db_field['message']=nl2br($db_field['message']); echo "<div id=\"article_body\">" .$db_field['message'] ."</div>";}[/code] Is there a way to have the output separated it when viewing the html source code? so it looks nice and neat? Quote Link to comment Share on other sites More sharing options...
tippy_102 Posted October 24, 2006 Share Posted October 24, 2006 Adding a /n will give you a line break:echo "<div id=\"article_body\">" .$db_field['message'] ."</div>/n"; Quote Link to comment Share on other sites More sharing options...
xfezz Posted October 24, 2006 Author Share Posted October 24, 2006 ok ty i got the line break. its \n btw not /n. another quick question. I have seen some sites that have the html source code lines indented. obviously it was generated code. anyone know how they did that? Quote Link to comment Share on other sites More sharing options...
tippy_102 Posted October 24, 2006 Share Posted October 24, 2006 They probably use a tab (or two) for that - \t Quote Link to comment Share on other sites More sharing options...
Psycho Posted October 24, 2006 Share Posted October 24, 2006 Or you could simply include the spaces/tabs within the echo statements. This:[code]<?phpecho "<table>\n";echo " <tr>\n";echo " <td>Data1</td>\n";echo " <td>Data2</td>\n";echo " <td>Data3</td>\n";echo " </tr>\n";echo "</table>\n";?>[/code]Will output this:[code]<table> <tr> <td>Data1</td> <td>Data2</td> <td>Data3</td> </tr></table>[/code] 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.