jrws Posted April 14, 2009 Share Posted April 14, 2009 Hey guys, I don't know how to fix this problem, I have tried trim and everything. Please have a look at the picture included to see what I mean by white space: Its annoying because as I have said, I can't figure it out. Its not the database I have checked it, anyway here is the code to go along with it. <?php //View News $title = 'News'; require_once ('libary/header.php'); if (isset($_GET['id']) && is_numeric($_GET['id']) && isset($_GET['edit']) &&is_numeric($_GET['id'])) { $id = $_GET['id']; $sql = "SELECT * FROM news WHERE id = '$id'"; $result = mysql_query($sql)or die(mysql_error()); $row = mysql_fetch_array($result); $u_id = $row['u_id']; if ($_SESSION['u_id'] == $u_id || $_SESSION['u_level'] == 6){ if(!isset($_POST['submit'])){ ?><form action="<? echo $PHP_SELF; ?>" method = "post"> Title:<input type="text" name = "title" value="<?=$row['title'];?>" size="32"><br> Author:<input type = "text" name = "author" disabled = "true" value = "<?=$row['author'];?>"><br> <textarea name = "data" id = "textbox"> <?=trim($row['data']);?> </textarea> <br> <input type = "submit" value = "Submit" name = "submit"> </form><? }else{ $error = array(); $title = clean($_POST['title']); $data = clean($_POST['data']); $update = "UPDATE news SET title = '$title', data = '$data' WHERE id='$id'"; $update_result = mysql_query($update)or die(mysql_error()); if($update_result){ echo 'Successfully updated article!<a href="'.$siteURL.'view_news.php?id='.$id.'"> View the updated post</a>'; }else{ echo '<div class="error">Did not update article successfully. Please try <a href="'.$siteURL.'view_news.php?id='.$id.'&edit='.$id.'">again</a></div>'; } } }else{ echo 'Not authorised to view this page!'; } } elseif (isset($_GET['id']) && is_numeric($_GET['id'])) { $id = clean($_GET['id']); $sql2 = mysql_query("SELECT * FROM `news` WHERE id='$id'") or die(mysql_error()); $row = mysql_fetch_array($sql2); $u_id = $row['u_id']; $title = $row['title']; $data = trim(nl2br($row['data'])); $author = $row['author']; echo '<h1>' . strtoupper($title) . '</h1>'; echo '<small>By :<a href="' . $siteURL . 'profile.php?id=' . $row['u_id'] . '">' . $author . '</a><br></small>'; echo '<p>' . $data . '</p>'; if ($_SESSION['u_id'] == $u_id || $_SESSION['u_level'] == 6) { echo '<br> <a href="?id=' . $id . '&edit=' . $id . '">Edit this post</a>'; } else { } } else { //Pagination $table = 'news'; $rowsPerPage = 3; $data1 = 'title'; $data2 = 'data'; $link = 'post'; include_once ('Pagnation.php'); pagnation($table, $rowsPerPage, $data1, $data2, $link); /*Pagination*/ } require_once ('libary/footer.php'); ?> Quote Link to comment Share on other sites More sharing options...
.josh Posted April 14, 2009 Share Posted April 14, 2009 what does the rightclick > view source look like? Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted April 14, 2009 Share Posted April 14, 2009 <textarea name = "data" id = "textbox"> <?=trim($row['data']);?> </textarea> change to: <textarea name = "data" id = "textbox"><?=trim($row['data']);?></textarea> Quote Link to comment Share on other sites More sharing options...
jrws Posted April 14, 2009 Author Share Posted April 14, 2009 Thanks man, I would never have of figured it out otherwise, please correct me if I am wrong; What I had done was make it have white space before it? Thanks again -James- Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted April 14, 2009 Share Posted April 14, 2009 yep - what ever is in your markup between the open and close tag of a text area will be reflected in the browser. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.