Jump to content

How to make td data spacing below if the browser need to scroll


shebbycs

Recommended Posts

In the picture below show the result taking from taskreportview.php

 

If u can see on the Operation field when I insert the long data, the data move forward

 

My main question is how to make the data jump to below for example

 

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

 

to

 

aaaaaaaaaaaaaaaaaaaaaaaaa

aaaaaaaaaaaaaaaaaaaaaaaaa

 

 

 

//TaskReportview.php

<?php
 mysql_connect("localhost","root") or die ("could not connect to the mysql");
 mysql_select_db("kime") or die ("no database");
 $a=$_SESSION['branchcodename'];
 $b=$_SESSION['ID'];
 $sql2 = mysql_query("SELECT *,DATE_FORMAT(Task_Date, '%d/%m/%Y %l:%i %p') AS Task_Date FROM task_report WHERE ID='$b' ORDER BY Task_Date") or die(mysql_error());
 echo "<body  bgcolor='#F5D16A'>";
 echo "<center><img src ='OK.gif'></center><br>";
 echo "<center><h2>OPERATION REPORT</h2>";
 echo "<table><tr><td><h3>LOCATION</h3></td><td><h3>:</h3></td><td><h3>".$a."</h3></td></tr></table></center>";
 echo "<center><table border = '1'>";
 echo "<tr><th>DATE & TIME</th><th>STAFF NAME</th><th>TASK</th><th>OPERATION</th><th>ACTION & RESULTS</th></tr>";	 
  while($report = mysql_fetch_array($sql2))
 {
  echo "<tr align='center'><td>".$report['Task_Date']."</td>";
  echo "<td>".$report['Task_Name']."</td>";
  echo "<td>".$report['Task_Task']."</td>";
  echo "<td>".$report['Task_Operation']."</td> ";
  echo "<td>".$report['Task_Action']."</td> ";

 }
 echo"</table><h2><a href='taskreportform.php'>Add Task Form</a><br></h2><h2><a href='logout.php'>Logout</a></h2></center>";
 
?> 

 

 

 

06435835698285099654.jpg

Link to comment
Share on other sites

while($report = mysql_fetch_array($searchall))
     {
       echo "<tr align='center'><td>".$report['Task_Date']."</td>";
	   echo "<td>".$report['Branch_Codename']."</td>";
       echo "<td>".$report['Task_Name']."</td>";
 	   echo "<td>".$report['Task_Task']."</td>";
  	   echo "<td>".str_replace("\r","<br>",$report['Task_Operation'])."</td>";
  	   echo "<td>".nl2br($report['Task_Action'])."</td>";
       echo "<td>".$report['Check_By']."</td></tr>";
     }

This works perfect when using textarea in task operation and task action but the main problem was when we input data in textarea and we enter to line break then only it will convert using that str replace or nl2br but what I want when user input data in textarea, it will automatically line break without user 'Enter' input

Link to comment
Share on other sites

  • 3 weeks later...

Have you tried placing the input text within a DIV set to whatever width you set? This would force text that is longer than the specified DIV width to break back to the begining of the div on a new line.

echo "<td>" . str_replace("\r", "<br><div style='width: " . $div_width . "';>", $report['Task_Operation']) . "</div></td>";

replace $div_width with whatever you think it should be, or just set a variable so you can maybe make it adjustable via admin or w/e.

Edited by InoBB
Link to comment
Share on other sites

Do you really have values in your database that are 50+ characters without any spaces? This is a "problem" I see reported all the time - especially when someone is testing max length restrictions on fields. This is an edge case scenario that doesn't need to be fixed in my opinion. Unless you expect that those types of values are going to be valid it's not worth the time and effort to add logic to handle it.

 

But, to answer your question directly. I don't believe there is any way, with just HTML and CSS, to make a line of characters with no spaces or other "break" characters (dash, period, tab, etc.) break across lines. You would have to do that in server-side code.

Link to comment
Share on other sites

  • 3 weeks later...

It's called a chat room, and a user trying to mess up the layout.

 

Really? Your supposed example was an "Operation Report" which one would naturally assume is for business purposes. If someone in a company is purposefully submitting data to corrupt the layout I would consider that a personnel issue.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.