Webmaster Key - Discussion Forums


Welcome, Guest. Please login or register.
Did you miss your activation email?
February 09, 2012, 06:14:13 AM

Login with username, password and session length
Welceome to Forums!

Important information for guests and new members:

In order to understand the full benefits of becoming an active member of this forum, please review the following information on guest and new member restrictions. These forum changes have been prompted by an overwhelming and unreasonable amount of bot postings and incoherent guest spam messages. We wish to prevent these events from happening in the future and make our community a more comfortable place for all of our members.

For guests:

Guests are not allowed to open new topics, polls, or posts attachments.
If you wish to open up new discussions on this forum, we encourage you to register.

For new members:

New members with less than five posts are not allowed to modify additional profile information such as avatars, contact information, biographies, and signatures. However, new members are encouraged to post their own topics or reply to topics initiated by other members. Become active on the forums and 5 posts should be an easy task!

We are a diverse community with members from all over the world. We encourage new ideas and interesting conversation. Do not be afraid to post webmaster/computer-related questions or problems, as our active members are always willing to help when they are able. Interested? Join us.

+ Webmaster Key Forums
|-+ Webmaster Corner
| |-+ Site Design and Web Authoring
| | |-+ Coding Talk
| | | |-+ Need help with wrapping text in php
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Go Down Stumble Upon! Digg It! del.icio.us! Add to Technorati! ReddIt!  Send this topic Print
Author Topic: Need help with wrapping text in php  (Read 6379 times)
Menard
Key Keeper
Veteran
*****
Posts: 965



WWW
« on: May 23, 2007, 01:43:46 PM »

The blog hosting script I am using at z54 has a lttile bug in that it won't wrap text; if you don't place breaks in the text you write, you end up with an incredibly wide page.

The script designers own blog hosting does not have that problem. I have asked him how to do it, and he has provided the code, but still has not answered 'where should I place that in the code'.


The code he has provide is:
Code:
$text=nl2br($text);

The index.php file is:
Code:
<?php
session_start
();
include 
"admin/connect.php";
$blogadmin=$_SESSION['blogadmin'];
$getadmin="SELECT * from bl_admin where username='$blogadmin'";
$getadmin2=mysql_query($getadmin) or die("Cannot get admin");
$getadmin3=mysql_fetch_array($getadmin2);
$title="Z54 Free Blog Hosting";
include 
"smiley.php";
include 
"admin/connect.php";
print 
"<link rel='stylesheet' href='style.css' type='text/css'>";
print 
"<title>$title</title>";
print 
"<table>";
print 
"<tr><td valign='top' width=20%>";
print 
"<center><table class='maintable'><tr class='headline'><td><center>Login</center></td></tr>";
print 
"<tr class='mainrow'><td>";
print 
"<form action='admin/authenticate.php' method='post'>";
print 
"Username:<br>";
print 
"<input type='text' name='username' size='20'><br>";
print 
"Password:<br>";
print 
"<input type='password' name='password' size='20'><br>";
print 
"<input type='submit' name='submit' value='submit'>";
print 
"</form><br>";
print 
"<A href='signup.php'><b>Sign Up</b></a>";
print 
"</td></tr></table><br><br>";
print 
"<table class='maintable'><tr class='headline'><td><center>Member Forums</center></td></tr>";
print 
"<tr class='mainrow'><td><li><A href='/blogs/forums/'>Member Forums</a></td></tr>";
print 
"</td></tr></table><br><br>";
print 
"<table class='maintable'><tr class='headline'><td><center>Latest 10 Updated Blogs</center></td></tr>";
//now grab the latest updated blogs
$getblogs="SELECT a.username
     , max(b.realtime)  as maxtime
  from bl_blog b
     , bl_admin a 
 where a.adminid=b.author 
group 
    by a.adminid
order
    by maxtime desc limit 10"
;

$getblogs2=mysql_query($getblogs) or die(mysql_error());
while(
$getblogs3=mysql_fetch_array($getblogs2))
{
  print 
"<tr class='mainrow'><td><A href='members.php?membername=$getblogs3[username]'>$getblogs3[username]</a></td></tr>";
}
print 
"</table>";
print 
"</td>";
print 
"<td valign='top' width=60%><center>";
$getannouncements="SELECT * from bl_accouncements order by thetime desc limit 10"//selects last ten announcements
$getannouncements2=mysql_query($getannouncements) or die(mysql_error());
while(
$getannouncements3=mysql_fetch_array($getannouncements2))

   print 
"<table class='maintable'><tr class='headline'><td><center>$getannouncements3[anntitle] post at $getannouncements3[thedate]</center></td></tr>";
   print 
"<tr class='mainrow'><td><p>$getannouncements3[announcement]";
   if(
$getadmin3[status]==3)
   {
      print 
"<br><br><A href='admin/editann.php?annid=$getannouncements3[annid]'>Edit Announcement</a>-<A href='admin/deleteann.php?annid=$getannouncements3[annid]'>Delete Announcement</a>";
   }
   print 
"</td></tr></table><br>";
}

print 
"</td>";
print 
"<td valign='top' width=20%>";
include 
"poll.php";
print 
"<br><br>";
print 
"<table class='maintable'><tr class='headline'><td><center>Search</center></td></tr>";
print 
"<tr class='mainrow'><td><form action='searchmem.php' method='post'>";
print 
"<input type='text' name='searchterm' size='15'>&nbsp;&nbsp;<input type='submit' name='submit' value='submit'></form></td></tr></table>";
print 
"</td></tr></table><br><br>";
print 
"<center><font size='2'>Powered by © <A href='http://www.chipmunk-scripts.com'>Chipmunk Blogger</a></center>";
?>



I was wondering if anyone had any suggestions on where I should place the snippet, or any other suggestions for getting text to wrap.
Report to moderator   Logged

iaimang
Limited Member

Posts: 7


« Reply #1 on: August 23, 2007, 07:40:08 PM »

first you have to put all your prints into a HERE doc

from
Code:
print "<link rel='stylesheet' href='style.css' type='text/css'>";
print "<title>$title</title>";

to
Code:
$string =<<<EOT
<link rel='stylesheet' href='style.css' type='text/css'>
<title>$title</title>
EOT


You can use one variable for all prints. don't forget to use .= in while or other structures.
On new $string variable remove all <br>

at the end of your code use
print nl2br($string); that's all



Report to moderator   Logged

iaimang
Limited Member

Posts: 7


« Reply #2 on: August 23, 2007, 07:41:31 PM »

first you have to put all your prints into a HERE doc

from
Code:
print "<link rel='stylesheet' href='style.css' type='text/css'>";
print "<title>$title</title>";

to
Code:
$string =<<<EOT
<link rel='stylesheet' href='style.css' type='text/css'>
<title>$title</title>
EOT

in while , if structures you can use

Code:
$string .= "print string here"
or
$string .= <<<EOT
print string here
EOT;

if you have more than one line.

You can use one variable for all prints. don't forget to use .= in while or other structures.
On new $string variable remove all <br>

at the end of your code use
print nl2br($string); that's all




Report to moderator   Logged

iaimang
Limited Member

Posts: 7


« Reply #3 on: August 23, 2007, 07:43:35 PM »

read only my last post. sorry for my other post. wrong button
Report to moderator   Logged

Pages: [1] Go Up Stumble Upon! Digg It! del.icio.us! Add to Technorati! ReddIt!  Send this topic Print 
+ Webmaster Key Forums
|-+ Webmaster Corner
| |-+ Site Design and Web Authoring
| | |-+ Coding Talk
| | | |-+ Need help with wrapping text in php

Jump to:  
« previous next »


Our Partners
RelmaxTOP Ranking System Web Hosting RelmaxTOP Ranking System
Staff Sites
12Noon[12Noon Gallery] Andy[Urgentclick]
Tamuril[Tamuril's Digital Art Exhibit] Sensovision
Powered by MySQL Powered by PHP We are hosted by Relmax Inc. |Our Privacy Policy | Sitemap
Powered by SMF 1.1.9 | SMF © 2006-2009, Simple Machines LLC
Forum design by Tamuril © 2005.
Valid XHTML 1.0! Valid CSS!