|  | Posted by m.shidoshi on 04/27/06 03:39 
I was recently put in charge of heading up my company's website, andwhile I have a lot of experience on the design side of things, I'm
 still very new to the programming side. When I started, the website had
 just gotten a revision, but the site was an utter mess, so I've been
 trying to fix it up. As I've gone along, I've learned some aspects of
 PHP, but my knowledge is still very limited.
 
 Here is the problem I'm trying to fix. A backend is used to enter
 information into our MySQL database, and then a page template pulls it
 out to make the page. For our reviews, the PHP coding currently breaks
 up the review's text so that it can be places across multiple pages.
 The problem is, the way the text breaking was set up, the end of one
 page and the beginning of the next are totally chaotic, with breaks
 often coming mid-sentence.
 
 Here is what I'd love: other coding automatically puts an HTML break at
 the end of paragraphs, and then another in the space between one
 paragraph and the next. I'd love to have the code search for when those
 double breaks come up, and then break up the text after, say, every
 sixth pair of HTML breaks. I'd also like the option to break the text
 myself by putting in some sort of text code in the original text. At
 this point, though, anything that can make the breaks more elegant
 would be a huge improvement.
 
 I really appreciate any help anybody can give me in this one. Please
 remember that I know very little of PHP, and I'm not much of a
 programmer anyhow, so things that you may take for granted that people
 would understand about PHP, I might not know.
 
 I tried to pull out what I thought was the current coding for the text
 break. Here it is. I'd also like to get rid of the part1/part2 factor.
 Before, they had the text breaking to help in fitting into the layout
 around an image, but I've fixed that so I no longer need the break. So,
 that portion no longer needs to be a factor.
 
 
 if ($page == ""){
 $page = 1;
 }
 $no_letters = strlen($Game_Full_Story);
 $times = ($no_letters / 3800) +1;
 $Game_Full_Story = wordwrap($Game_Full_Story,3800,"*#^");
 $Game_Full_Story = explode ("*#^", $Game_Full_Story);
 $pages = array();
 for ($i=0; $i<$times ; $i++){
 $part[$i] = $Game_Full_Story[$i];
 if ($i != 0){
 array_push($pages, $i);
 }
 }
 $page = $page-1;
 $story = $part[$page];
 if (strlen($story) < 460){
 $parts1 = $story;
 }else{
 $story = wordwrap($story,460,"*#^");
 $story = explode ("*#^", $story);
 $parts1 = $story[0];
 $count = count($story);
 $parts2="";
 for ($i=1; $i<$count; $i++){
 $parts2 .=$story[$i];
 $parts2 .=" ";
 }
 }
  Navigation: [Reply to this message] |