coleby58 Posted March 22, 2009 Share Posted March 22, 2009 Hello there I'm sorry if this has already been solved somewhere I have looked for a while. I have a website where a user submits information in a form on a page then on submit the next page displays there info. What I need is when there info reaches a certain length in the DIV on the display page I need it to go drop to the next line and indent 5 spaces. All my pages refer to my css page so it would be nice if I could put one code in that page instead of on 100 pages. here is an example of how I have the display page set up: <html> <head> <title>Example</title> <link rel="stylesheet" type="text/css" href="example.css"/> <script type="text/javascript" src="example.js"></script> </head> <body> <center> <div id="logo"> <a href="index.php"> <img border="0" src="example.JPG"> </a> </div></center> <div id="example"> <?php $info = $_POST['info']; if ($info=="") echo ""; else echo "$info"; ?> </div> </body> </html> ---------------------------------------------------------- As you can see there info is displayed with php. I'm still a begginer so I'm sorry if css is not the solution to my problem. Quote Link to comment Share on other sites More sharing options...
seaweed Posted March 22, 2009 Share Posted March 22, 2009 <?php $info = $_POST['info']; // grabs the data from the form $length=strlen($info); // checks the length of the data string if ($length < 30) { // decides WTH to do next $info = $info; // leaves it as is, it's shorter than 30 } else { $info = substr("$info",0,30) . "..."; // splits it into two lines (starts at character 0 and goes thirty spaces, then cuts it.) $info2 = substr("$info",31,30); // you could add a third line by using ("$info",62,30) or whatever } echo "$info<br /> // say it, don't spray it $info2"; // adds 5 spaces then prints characters 31 onward. ?> Now, you could put all of this in a file called displayinfo.php and then include it on any page you need it on with <?php include ('displayinfo.php') ?> This should work, I didn't test it and I am tired but it's php 101. 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.