formatting of text froma a dynamic table in dreamweaver

This is a discussion on "formatting of text froma a dynamic table in dreamweaver" within the Databases section. This forum, and the thread "formatting of text froma a dynamic table in dreamweaver are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > Databases

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Nov 21st, 2006, 11:13
Junior Member
Join Date: Oct 2005
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
formatting of text froma a dynamic table in dreamweaver

I am trying to slowly put together a very simple content management site for a footy club i run,

the data is stored in a mysql database and lined to the web page using a dynamic table from within dreamweaver, it displays all the info except one thing it appears in one huge paragraph, take a look at my page

Link is at:

http://itdesignz.co.uk/Clients/RTFC/cms/home.php

The Data in the mysql has the spaces and enters breaks in it, but these are not reflected in my page.

I am really new to dreamweaver and am not sure how to overcome this problem,

my page code is:

Code: Select all
<?php require_once('Connections/rtfccms.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  $insertSQL = sprintf("INSERT INTO news (headline, story, `date`, active, archive) VALUES (%s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['headline'], "text"),
                       GetSQLValueString($_POST['story'], "text"),
                       GetSQLValueString($_POST['date'], "date"),
                       GetSQLValueString(isset($_POST['active']) ? "true" : "", "defined","1","0"),
                       GetSQLValueString(isset($_POST['archive']) ? "true" : "", "defined","1","0"));

  mysql_select_db($database_rtfccms, $rtfccms);
  $Result1 = mysql_query($insertSQL, $rtfccms) or die(mysql_error());

  $insertGoTo = "home.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
<!--
body {
    background-color: #FFFFFF;
}
.style2 {
    color: #006633;
    font-weight: bold;
    font-size: 18px;
}
.style3 {
    color: #006603;
    font-weight: bold;
    font-size: 24px;
}
-->
</style></head>

<body>
<table width="935" height="325" border="1" align="center" bordercolor="#006700">
  <tr>
    <td height="93"><img src="images/top_image.jpg" width="974" height="89" longdesc="http://www.redtilefc.co.uk" /></td>
  </tr>
  <tr>
    <td height="34"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="100" height="22">
      <param name="movie" value="button1.swf" />
      <param name="quality" value="high" />
      <param name="bgcolor" value="#FFFFFF" />
      <embed src="button1.swf" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="100" height="22" bgcolor="#FFFFFF"></embed>
    </object>
      <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="100" height="22">
        <param name="movie" value="button2.swf" />
        <param name="quality" value="high" />
        <param name="bgcolor" value="#FFFFFF" />
        <embed src="button2.swf" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="100" height="22" bgcolor="#FFFFFF"></embed>
      </object></td>
  </tr>
  <tr>
    <td height="158"><p class="style3">Insert A New Story  
      <form method="post" name="form1" action="<?php echo $editFormAction; ?>">
        <table width="378" align="center">
          <tr valign="baseline">
            <td nowrap align="right">Headline:</td>
            <td><input type="text" name="headline" value="" size="70"></td>
          </tr>
          <tr valign="baseline">
            <td height="95" align="right" nowrap>Story:</td>
            <td><textarea name="story" cols="70" rows="15"></textarea></td>
          </tr>
          <tr valign="baseline">
            <td nowrap align="right">Active:</td>
            <td><input type="checkbox" name="active" value="" ></td>
          </tr>
          <tr valign="baseline">
            <td nowrap align="right">Archive:</td>
            <td><input type="checkbox" name="archive" value="" ></td>
          </tr>
          <tr valign="baseline">
            <td nowrap align="right">&nbsp;</td>
            <td><input type="submit" value="Insert record"></td>
          </tr>
        </table>
        <input type="hidden" name="MM_insert" value="form1">
      </form>
    <p>&nbsp;</p></td>
  </tr>
  <tr>
    <td height="28"><p align="center" class="style2">Site built and maintained By <a href="www.itdesignz.co.uk">IT Designz</a> </p>    </td>
  </tr>
</table>
</body>
</html>
Please help

Andy
Reply With Quote

  #2 (permalink)  
Old Jan 1st, 2007, 19:50
Up'n'Coming Member
Join Date: Feb 2006
Location: London
Age: 25
Posts: 98
Thanks: 0
Thanked 0 Times in 0 Posts
Re: formatting of text froma a dynamic table in dreamweaver

I know you probably found the answer already, but just incase anyone needs it in the future... This function swaps '\n' for '<br />'

nl2br($string);

Reply With Quote
  #3 (permalink)  
Old Jan 2nd, 2007, 10:09
Most Reputable Member
Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,310
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Skype™ to ukgeoff
Re: formatting of text froma a dynamic table in dreamweaver

Can't remember where I first came across this function but it will take a chunk of data and add the necessary paragraph and break tags so your data looks right on the page.
Code: Select all
function autop($pee, $br=1) { 
    $txt = $pee;
    $txt = preg_replace("/(\r\n|\n|\r)/", "\n", $txt); // cross-platform newlines 
    $txt = preg_replace("/\n\n+/", "\n\n", $txt); // take care of duplicates 
    $txt = preg_replace('/\n?(.+?)(\n\n|\z)/s', "<p>$1</p>\n", $txt); // make paragraphs, including one at the end 
    if ($br) $txt = preg_replace('|(?<!</p>)\s*\n|', "<br />\n", $txt); // optionally make line breaks 
    return $txt; 
}
Reply With Quote
Reply

Tags
formatting mysql

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
text formatting questions Lchad Web Page Design 7 Jan 27th, 2007 23:05
Text formatting trouble BGarner Web Page Design 4 Jan 8th, 2007 11:47
XSL FO Table formatting davedran Other Programming Languages 0 Dec 13th, 2006 07:35
Formatting Text - XML newbie wants everything! AceTutor Other Programming Languages 0 Apr 28th, 2006 13:53
help with formatting this javascirpt text...please! newbie44 JavaScript Forum 2 Sep 29th, 2005 14:08


All times are GMT. The time now is 09:39.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43