Jump to content

Preserving spaces in table output


twilitegxa

Recommended Posts

I'm having some trouble with displaying my white space between words. I have a table that holds records for resumes, and the administrator can access each record and edit them. I have the record displayed in text boxes for editing, but the white space between words is not showing up. Only the first word will show up. I have tried changing the field type in the table to text or blob instead of varchar, and I have tried using the nl2br function when displaying the records, but that isn't working either. What am I doing wrong? Here is my edit page:

 

<?php

$applicant = "SELECT * FROM applicants WHERE id = '$_GET[id]'";
$applicant_res = mysql_query($applicant, $conn) or die(mysql_error());

$display_block = "<h3>Edit Entry</h3>
<p>To edit the entry, change any relevant information below:</p>

<form method=post action=update_U3IP.php><table>";

while ($applicants_list = mysql_fetch_array($applicant_res)){
$id = $applicants_list['id'];
$firstname = $applicants_list['firstname'];
$lastname = $applicants_list['lastname'];
$address = $applicants_list['address'];
$city = $applicants_list['city'];
$state = $applicants_list['state'];
$zip = $applicants_list['zip'];
$phone = $applicants_list['phone'];
$position = nl2br($applicants_list['position']);
$file = $applicants_list['resume'];

$display_block .= "
<table>
<tr>
<td><label for=id><b>ID:</b></label></td>
<td><input name=id type=text size=2 id=id value=$id /></td>
</tr>
<tr>
<td><label for=firstname><b>First Name:</b></label></td>
<td><input name=firstname type=text size=20 id=firstname value=$firstname /></td>
</tr>
<tr>
<td><label for=lastname><b>Last Name:</b></label></td>
<td><input name=lastname type=text size=20 id=lastname value=$lastname /></td>
</tr>
<tr>
<td><label for=address><b>Address:</b></label></td>
<td><input name=address type=text size=20 id=address value=$address /></td>
</tr>
<tr>
<td><label for=city><b>City:</b></label></td>
<td><input name=city type=text size=20 id=city value=$city /></td>
</tr>
<tr>
<td><label for=state><b>State:</b></label></td>
<td><input name=state type=text size=20 id=state value=$state /></td>
</tr>
<tr>
<td><label for=zip><b>Zip:</b></label></td>
<td><input name=zip type=text size=20 id=zip value=$zip /></td>
</tr>
<tr>
<td><label for=phone><b>Phone:</b></label></td>
<td><input name=phone type=text size=20 id=phone value=$phone /></td>
</tr>
<tr>
<td><label for=position><b>Position:</b></label></td>
<td><input name=position type=text size=20 id=position value=$position /></td>
</tr>
<tr>
<td><b>Uploaded Resume:</b></td>
<td><input type=text name=file id=file value=$file /></td>
</tr>
<tr>
<td colspan=2> </td>
</tr>
<tr>
<td colspan=2 align=center>
<input type=hidden name=hidden_id id=hidden_id value=$id />
<input type=submit value=Submit />
<a href=admin_U3IP.php><input type=button name=back id=back value=Back /></a></td>
</tr>";

}

$display_block .= "</table></form>";

?>

<!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=utf-8" />
<title>KulaE_WDP4451_U3IP</title>
</head>
<body>
<?php echo $display_block; ?>
</body>
</html>

Link to comment
Share on other sites

The problem could be a couple of different places. Youshould validate the actual content in the database and the content in the HTML page. Just because you can't "see" the text in the web page doesn't mean it is not there. Check the HTML page source to see if the content is there. The problem might be with the content being interpreted as HTML code. If that is the case you will need to use something like htmlentities() to convert the HTML code characters to their character code equivalents.

Link to comment
Share on other sites

I checked the source of the page and the additional text was showing up, like you said. How would I used htmlentities()? I tried doing it like this:

 

$position = htmlentities($applicants_list['position']);

 

But it didn't work. What did I do wrong?

 

I should this when I view the source:

 

<tr>
<td><label for=position><b>Position:</b></label></td>
<td><input name=position type=text size=20 id=position value=Technical Support /></td>
</tr>

 

The word "Support" is in red, even with htmlentities() being used.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.