RE: [PHP] Calling functions! Newbie problem!

From: Date: Wed, 18 Oct 2000 08:29:25 +0000
Subject: RE: [PHP] Calling functions! Newbie problem!
Groups: php.general 
Request: Send a blank email to php-general+get-20840@lists.php.net to get a copy of this message
why not to use a simple HTML table? -----Original Message----- From: Ivanoff Jari [mailto:Jari.Ivanoff@autonova.se] Sent: Wednesday, October 18, 2000 5:22 PM To: Maxim Maletsky Subject: RE: [PHP] Calling functions! Newbie problem! Yeah... I have a field in a database that is 500 chars long and I need to wrap it to 75 columns width when i present the data. /Jari > -----Original Message----- > From: Maxim Maletsky [SMTP:maxim@japaninc.net] > Sent: den 18 oktober 2000 10:12 > To: 'Ivanoff Jari' > Cc: 'PHP General List. (E-mail)' > Subject: RE: [PHP] Calling functions! Newbie problem! > > Correct me if I am wrong but I think I saw a new function in the latest > PHP > 4.0.3 called word_wrap() > > is that what you are trying to do? > > -----Original Message----- > From: Ivanoff Jari [mailto:Jari.Ivanoff@autonova.se] > Sent: Wednesday, October 18, 2000 4:56 PM > To: 'PHP' > Subject: [PHP] Calling functions! Newbie problem! > > > Well.. here we go again! > I have script that prints out some text from a database. > I have now found a function that does a wordwrap on the text. > I run my printout routine in a loop for 5 times to print out the 5 latest > entrys in the database. > I have declared the routine outside the loop. > I found the function in LinuxGurus > But how do I call the routine to handle the text? > I do not get any errormessage, but the "content" don't get printed. > It is for a newspage. > Here is my pretty lame attempt. > > <?php > $string = $content; > $cols = 75; > $prefix = ""; > > function wrap_text ($string, $cols, $prefix) { > $t_lines = split( "\n", $string); > $outlines = ""; > while(list($foo, $thisline) = each($t_lines)) > { > if(strlen($thisline) > $cols) > { > $newline = ""; > $t_l_lines = split(" ", $thisline); > while(list($bar, $thisword) = each($t_l_lines)) > { > if((strlen($newline) + strlen($thisword)) > $cols) > { > $outlines .= $prefix.$newline."\n"; > $newline = $thisword." "; > } else { > $newline .= $thisword." "; > } } > $outlines .= $prefix.$newline."\n"; > } else { > $outlines .= $prefix.$thisline."\n"; > } } > return $outlines;} > > $db = mssql_connect("wsean1567","www","www")or die("Gick > inte att > ansluta."); > mssql_select_db("VCU_Intranet",$db)or die("Kunde inte välja databas."); > $result = mssql_query("SELECT date,time,head,content,urgent FROM tbl_news > ORDER BY date DESC,time desc;")or die("Kunde inte utföra frågan."); > > > for ($count=0;$count <= 5;$count++) > { > $decide_color = mssql_result($result,$count,"urgent"); > if ($decide_color > 0 ) > { > $color = "#ff0000"; > } else { > $color = "#000000"; > } > > $date = mssql_result($result,$count,"date"); > printf("<font size =\"-2\">$date</font>\n"); > $time = mssql_result($result,$count,"time"); > printf("<font size =\"-2\">$time</font><br>\n"); > > $head = mssql_result($result,$count,"head"); > printf("<font color = $color >$head</font><br>\n"); > > $content = mssql_result($result,$count,"content"); > printf("$outlines"); > > } > ?> > > /Jari Ivanoff > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#20840) next »