I am uploading news articles to a MySQL db by splitting the article into 255 character strings and then uploading to separate fields.
When a user wished to view a news story I am then grabbing all the fields joining them together and then outputting the article.
the problem I am having id the text comes out as one long line of text with the formatting(line breaks) missing.
So i tried <pre> but that ignored the page width
I then tried <pre> with width declared but that is ignored in some browsers.
I thought about putting the <pre> tag inside a div with a max width property set in the div but I am also using sandbags for outputting the text around the picture that matches the story and some images are wider than others so I cannot set the width in the stylesheet
I have looked around the web and there are plenty of sites that do this (ie newspaper sites)
there must be a simple solution
heres the code
<div id="full_news_content">
<?
$spare1=0;
require("connect.php");
$ref=$_REQUEST['ref'];
$sql="SELECT * FROM news WHERE ref = '$ref' ORDER BY mid(date1,7,4) DESC, mid(date1,4,2) DESC, mid(date1,1,2) DESC";
$rs=mysql_query($sql);
$num=mysql_num_rows($rs);
while ($row=mysql_fetch_array($rs))
{
$spare1=$row['spare1'];
$date1=$row['date1'];
$title=$row['title'];
$ref=$row['ref'];
$desc1=$row['news1'];
$desc2=$row['news2'];
$desc3=$row['news3'];
$desc4=$row['news4'];
$desc5=$row['news5'];
$desc6=$row['news6'];
$desc7=$row['news7'];
$desc8=$row['news8'];
$desc9=$row['news9'];
$desc10=$row['news10'];
$desc11=$row['news11'];
$desc12=$row['news12'];
$desc13=$row['news13'];
$desc14=$row['news14'];
$desc15=$row['news15'];
$desc16=$row['news16'];
$desc17=$row['news17'];
$desc18=$row['news18'];
$desc19=$row['news19'];
$desc20=$row['news20'];
$desc21=$row['news21'];
$desc22=$row['news22'];
$desc23=$row['news23'];
$desc24=$row['news24'];
$desc25=$row['news25'];
$desc26=$row['news26'];
$desc27=$row['news27'];
$desc28=$row['news28'];
$desc29=$row['news29'];
$desc30=$row['news30'];
$item=$desc1.$desc2.$desc3.$desc4.$desc5.$desc6.$desc7.$desc8.$desc9.$desc10.$desc11.$desc12.$desc13.$desc14.$desc15.$desc16.$desc17.$desc18.$desc19.$desc20.$desc21.$desc22.$desc23.$desc24.$desc25.$desc26.$desc27.$desc28.$desc29.$desc30;
$sql1="SELECT * FROM news_images WHERE ref = '$ref'";
$rs1=mysql_query($sql1);
$num1=mysql_num_rows($rs1);
while ($row1=mysql_fetch_array($rs1))
{
$image="../images/news/".$row1['image'];
}
if($image!='')
{
?>
<div id="news_image" ><img src="<? echo $image; ?>" height="400"></div>
<div id="news_item"><div class="style7" align="center"><? echo $date1; ?> <? echo $title; ?></div><br><span class="newstext"><pre><? echo $item; ?></pre></span></div>
<?
}
else
{
?> <div id="news_item"><div class="style7" align="center"><? echo $date1; ?> <? echo $title; ?></div><br><div class="newstext"><pre><? echo $item; ?></pre></div></div>
<?
}
} ?>
</div>
When a user wished to view a news story I am then grabbing all the fields joining them together and then outputting the article.
the problem I am having id the text comes out as one long line of text with the formatting(line breaks) missing.
So i tried <pre> but that ignored the page width
I then tried <pre> with width declared but that is ignored in some browsers.
I thought about putting the <pre> tag inside a div with a max width property set in the div but I am also using sandbags for outputting the text around the picture that matches the story and some images are wider than others so I cannot set the width in the stylesheet
I have looked around the web and there are plenty of sites that do this (ie newspaper sites)
there must be a simple solution
heres the code
<div id="full_news_content">
<?
$spare1=0;
require("connect.php");
$ref=$_REQUEST['ref'];
$sql="SELECT * FROM news WHERE ref = '$ref' ORDER BY mid(date1,7,4) DESC, mid(date1,4,2) DESC, mid(date1,1,2) DESC";
$rs=mysql_query($sql);
$num=mysql_num_rows($rs);
while ($row=mysql_fetch_array($rs))
{
$spare1=$row['spare1'];
$date1=$row['date1'];
$title=$row['title'];
$ref=$row['ref'];
$desc1=$row['news1'];
$desc2=$row['news2'];
$desc3=$row['news3'];
$desc4=$row['news4'];
$desc5=$row['news5'];
$desc6=$row['news6'];
$desc7=$row['news7'];
$desc8=$row['news8'];
$desc9=$row['news9'];
$desc10=$row['news10'];
$desc11=$row['news11'];
$desc12=$row['news12'];
$desc13=$row['news13'];
$desc14=$row['news14'];
$desc15=$row['news15'];
$desc16=$row['news16'];
$desc17=$row['news17'];
$desc18=$row['news18'];
$desc19=$row['news19'];
$desc20=$row['news20'];
$desc21=$row['news21'];
$desc22=$row['news22'];
$desc23=$row['news23'];
$desc24=$row['news24'];
$desc25=$row['news25'];
$desc26=$row['news26'];
$desc27=$row['news27'];
$desc28=$row['news28'];
$desc29=$row['news29'];
$desc30=$row['news30'];
$item=$desc1.$desc2.$desc3.$desc4.$desc5.$desc6.$desc7.$desc8.$desc9.$desc10.$desc11.$desc12.$desc13.$desc14.$desc15.$desc16.$desc17.$desc18.$desc19.$desc20.$desc21.$desc22.$desc23.$desc24.$desc25.$desc26.$desc27.$desc28.$desc29.$desc30;
$sql1="SELECT * FROM news_images WHERE ref = '$ref'";
$rs1=mysql_query($sql1);
$num1=mysql_num_rows($rs1);
while ($row1=mysql_fetch_array($rs1))
{
$image="../images/news/".$row1['image'];
}
if($image!='')
{
?>
<div id="news_image" ><img src="<? echo $image; ?>" height="400"></div>
<div id="news_item"><div class="style7" align="center"><? echo $date1; ?> <? echo $title; ?></div><br><span class="newstext"><pre><? echo $item; ?></pre></span></div>
<?
}
else
{
?> <div id="news_item"><div class="style7" align="center"><? echo $date1; ?> <? echo $title; ?></div><br><div class="newstext"><pre><? echo $item; ?></pre></div></div>
<?
}
} ?>
</div>