misslilbit02 Posted October 16, 2007 Share Posted October 16, 2007 Hi, I need a little help formatting data. When I print the data out I want it to indent every paragraph and return after every 7-10 lines. Can someone help me with this? Link to comment https://forums.phpfreaks.com/topic/73522-formatting-in-php/ Share on other sites More sharing options...
kenrbnsn Posted October 16, 2007 Share Posted October 16, 2007 This is not a PHP question. Formating is done with CSS. I will move the question. Ken Link to comment https://forums.phpfreaks.com/topic/73522-formatting-in-php/#findComment-370914 Share on other sites More sharing options...
SuperBlue Posted October 16, 2007 Share Posted October 16, 2007 <p style="text-indent:1em;margin:0 0 7em 0;">This is some Text</p> Reminder: The above margin is "margin: top right bottom left;". Link to comment https://forums.phpfreaks.com/topic/73522-formatting-in-php/#findComment-370927 Share on other sites More sharing options...
misslilbit02 Posted October 16, 2007 Author Share Posted October 16, 2007 Well this is a PHP question because I'm using PHP and a mysql database to output it to the browser. Sorry I wasn't clear about that. My question is how do I format data out of a mysql database? I know how to print tables and things of that nature and I know this is very elementary but I have all of these entries in a mysql database and I want format the output so that every entry that comes out has indented paragraphs and has break after every 7-10 lines of data. How do I go about doing that. Link to comment https://forums.phpfreaks.com/topic/73522-formatting-in-php/#findComment-370936 Share on other sites More sharing options...
SuperBlue Posted October 16, 2007 Share Posted October 16, 2007 Well this is a PHP question because I'm using PHP and a mysql database to output it to the browser. Sorry I wasn't clear about that. My question is how do I format data out of a mysql database? I know how to print tables and things of that nature and I know this is very elementary but I have all of these entries in a mysql database and I want format the output so that every entry that comes out has indented paragraphs and has break after every 7-10 lines of data. How do I go about doing that. <?php // Variables $passMYSQL = 'MyPassword'; $userMYSQL = 'MyUsername'; $databaseMYSQL = 'MyDatabase'; // Retrieve the data $CDB = mysql_connect('localhost', $userMYSQL, $passMYSQL); $db_selected = mysql_select_db($databaseMYSQL, $CDB); $datw = mysql_fetch_assoc(mysql_query("SELECT post, text, whatever FROM TestTable WHERE post = 'UniqueId'")); mysql_close($CDB); // return data from the text column where post id is UniqueId echo '<p style="text-indent:1em;margin:0 0 7em 0;">'.$datw["text"].'</p>'; ?> Note i expect things to work, so error checking was left out to speed up abit.. Link to comment https://forums.phpfreaks.com/topic/73522-formatting-in-php/#findComment-370944 Share on other sites More sharing options...
SuperBlue Posted October 16, 2007 Share Posted October 16, 2007 And with while loop: <?php // Variables $passMYSQL = 'MyPassword'; $userMYSQL = 'MyUsername'; $databaseMYSQL = 'MyDatabase'; // Used in the while loop $PostUniqueId = 1; // Retrieve the data $CDB = mysql_connect('localhost', $userMYSQL, $passMYSQL); $db_selected = mysql_select_db($databaseMYSQL, $CDB); while ($PostUniqueId <= 10) { $PostUniqueId++; $datw = mysql_fetch_assoc(mysql_query("SELECT post, text, whatever FROM TestTable WHERE post = '$PostUniqueId'")); // return data from the text column where post id is UniqueId echo '<p style="text-indent:1em;margin:0 0 7em 0;">'.$datw["text"].'</p>'; } mysql_close($CDB); ?> Edit: Replaced $i with $PostUniqueId, since i think it makes more sense... Link to comment https://forums.phpfreaks.com/topic/73522-formatting-in-php/#findComment-370964 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.