Can some of you guru's out there shed some light on this task in php?
Coming from mysql DB, have records with white space in there, hard returns. Is there a way in php to capture that whitespace for formatting?
I don't know the php code, this is what I am trying to port from (jsp) however:
<could not use php tags, as it is not php (sorry)>
<%
Clob cl = (Clob)data.get("article_x");
BufferedReader in = new BufferedReader(new InputStreamReader (cl.getAsciiStream()));
String str = null;
while((str = in.readLine()) != null)
{
out.println(str+"<br>");
}
%>
Short version of this is, how do I enter a hard break in html after returning my result set from mysql. Everywhere there is a break in the db I want to do in html, thus to kepp the formatting.
Thanks in advance....
tgaugh
Java Port, need php syn
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
It's been a long time since I've done JSP so...
Code: Select all
<?php
mysql_connect($server,$username,$password) or die(mysql_error());
mysql_select_db($dbname) or die(mysql_error());
$query = mysql_query("SELECT article FROM articles WHERE id = '2' LIMIT 1") or die(mysql_error());
if(mysql_num_rows($query) == 0)
die("no article found.");
$result = mysql_fetch_row($query);
$result = $result[0];
echo nl2br($result);
?>I have the connection function is php already, here is the issues
the resultset reads
article1article2article3article4
When the db reads
article1
article2
article3
article4
So when the result is captured is prints the single line no breaks, I want to identify as I do in the jsp code above how to determine the "white space" and then enter manually a <br>
Does that help?
Thanks!!!
tgaugh
the resultset reads
article1article2article3article4
When the db reads
article1
article2
article3
article4
So when the result is captured is prints the single line no breaks, I want to identify as I do in the jsp code above how to determine the "white space" and then enter manually a <br>
Does that help?
Thanks!!!
tgaugh
if all else fails, it only takes one second to visit php.net and read up on the suggested command. as it would be a much easier way for you to acheive your wishes
http://www.php.net
http://www.php.net