Jump to content

[SOLVED] White space :(


jrws

Recommended Posts

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:

whitespaceo.th.png

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');
?>

Link to comment
https://forums.phpfreaks.com/topic/153943-solved-white-space/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.