bindiya Posted December 17, 2010 Share Posted December 17, 2010 I hav a php page which takes data from the db.But the problem i am facing is for a particular fild in database ,i have long data,which i need to b displayed in a wordwrap way eg my data is " Description need a site for school gave order on 12-10-2010 work started on 12-10-2010 " this shuld be displayed as "Description need a site for school gave order on 12-10-2010 work started on 12-10-2010" Description is the field in the database and rest of them are the datas in it Quote Link to comment https://forums.phpfreaks.com/topic/221966-php-code-needed-in-displaying-the-datas-frm-db-in-a-new-line/ Share on other sites More sharing options...
denno020 Posted December 17, 2010 Share Posted December 17, 2010 What is your php code that you're using to get that data from your db and print it? Denno Quote Link to comment https://forums.phpfreaks.com/topic/221966-php-code-needed-in-displaying-the-datas-frm-db-in-a-new-line/#findComment-1148611 Share on other sites More sharing options...
bindiya Posted December 18, 2010 Author Share Posted December 18, 2010 $sql = "select * from product where reference_no = '".$reference_no."'"; $sqlquery = mysql_query($sql); $sql_project_fetch_array =mysql_fetch_array($sqlquery); echo "<table><tr> <td class="tableCellOne"> </td> <td class="tableCellOne">Description</td> <td class="tableCellOne"> <?php echo str_replace("<p>"," ",$sql_project_fetch_array['description']); ?></td> </tr> Quote Link to comment https://forums.phpfreaks.com/topic/221966-php-code-needed-in-displaying-the-datas-frm-db-in-a-new-line/#findComment-1148896 Share on other sites More sharing options...
denno020 Posted December 18, 2010 Share Posted December 18, 2010 You need to print more table rows. echo "<table><tr> <td class="tableCellOne"> </td></tr> <tr><td class="tableCellOne">Description</td></tr> <tr><td class="tableCellOne"> <?php echo str_replace("<p>"," ",$sql_project_fetch_array['description']); ?></td> </tr> Denno Quote Link to comment https://forums.phpfreaks.com/topic/221966-php-code-needed-in-displaying-the-datas-frm-db-in-a-new-line/#findComment-1148901 Share on other sites More sharing options...
bindiya Posted December 18, 2010 Author Share Posted December 18, 2010 i didnt understand what u were explaining Quote Link to comment https://forums.phpfreaks.com/topic/221966-php-code-needed-in-displaying-the-datas-frm-db-in-a-new-line/#findComment-1148903 Share on other sites More sharing options...
denno020 Posted December 18, 2010 Share Posted December 18, 2010 Well you are printing one row(<tr> </tr>), and then 3 cells (<td> </td>). This means they're all aligned horizontally on the same line. You want to print your data in a new cell, that's on a new row. I added <tr> </tr> tags to fix this. You will get the format of "Description need a site for school gave order on 12-10-2010 work started on 12-10-2010" Using this code. Denno Quote Link to comment https://forums.phpfreaks.com/topic/221966-php-code-needed-in-displaying-the-datas-frm-db-in-a-new-line/#findComment-1148904 Share on other sites More sharing options...
bindiya Posted December 18, 2010 Author Share Posted December 18, 2010 understood ur code.but some doubt ,suppose there are more lines of description for some id(another field,a primary key).Then how will i use this code? eg id description (no of rows) 1 4 rows are there 2 1 row only 3 8 rows Quote Link to comment https://forums.phpfreaks.com/topic/221966-php-code-needed-in-displaying-the-datas-frm-db-in-a-new-line/#findComment-1148906 Share on other sites More sharing options...
denno020 Posted December 18, 2010 Share Posted December 18, 2010 echo "<table> <tr><td>id</td> <td class="tableCellOne">Description</td></tr> <tr><td>1</td> <td class="tableCellOne">4 rows are there</td></tr> <tr><td>2</td> <td class="tableCellOne">1 row only</td></tr> <tr><td>3</td> <td class="tableCellOne">8 rows</td></tr> </table>" You'll notice that now there is two sets of <td> </td> between each <tr> </tr> tag. This means 2 cells on one row. I just did a google search for online HTML table generator. Look at this link and it will generate the code you need for a X column by Y rows. http://www.quackit.com/html/html_table_generator.cfm Denno Quote Link to comment https://forums.phpfreaks.com/topic/221966-php-code-needed-in-displaying-the-datas-frm-db-in-a-new-line/#findComment-1148908 Share on other sites More sharing options...
bindiya Posted December 18, 2010 Author Share Posted December 18, 2010 thanks for the google serach Quote Link to comment https://forums.phpfreaks.com/topic/221966-php-code-needed-in-displaying-the-datas-frm-db-in-a-new-line/#findComment-1148914 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.