Jump to content

Display issues.


ZombieToast

Recommended Posts

I'm really hoping someone can help me out here.  My fiancé and I are looking for a house and I thought it would help make things a bit more convenient if I created a mini-site for us to keep track of properties that we want to consider.  I could easily do this with HTML, but I wanted to put some of my [limited] PHP knowledge to use.  At the moment, I have three pages: a form for entering house information, a php script to process the form (and add it to a text file on my server), and a page to display all entered houses.

 

Most of it is actually working how I want it to, but I'm having a few minor problems.  The main one is that I can't get my table to display properly.  See here for an example.  I want each row to extend to the full width.  Is there a better way to build my table?  Another big problem is that if I enter more than one line into my Notes textarea box, it screws everything up (take a look at my page to see what I mean).  Is there a way to fix this without having to manually enter a line break when I type in the data?

 

At the moment, those are the only issues I'm having.  The main one I would like to fix is the display of my tables.  Thankfully, the script itself works without any issues (other than the Notes textarea that I mentioned).  Here is the script from my showhouses.php page...

 

$HouseArray = file("houselist.txt");
$HouseArray = array_unique($HouseArray);
sort($HouseArray);

for ($i=0; $i<count($HouseArray); ++$i) {
$Row = explode("__", $HouseArray[$i]);
echo "<table width='80%' border='1'>";
echo "<tr><td><strong>Price:</strong> " . stripslashes($Row[0]) . "</td></tr>";
echo "<tr><td><img src='pics/" . stripslashes($Row[1]) . ".jpg'></td></tr>";
echo "<tr><td><strong>Park Name:</strong><br />" . stripslashes($Row[2]) . "</td>";
echo "<td><strong>Address:</strong><br />" . stripslashes($Row[3]) . "</td>";
echo "<td><strong>Phone #:</strong><br />" . stripslashes($Row[4]) . "</td></tr>";
echo "<tr><td><strong>Built:</strong> " . stripslashes($Row[5]) . "</td>";
echo "<td><strong>MLS #:</strong> " . stripslashes($Row[6]) . "</td></tr>";
echo "<tr><td><strong>Monthly Dues:</strong> " . stripslashes($Row[7]) . "</td></tr>";
echo "<tr><td><strong>Bedrooms:</strong><br />" . stripslashes($Row[8]) . "</td>";
echo "<td><strong>Bathrooms:</strong><br />" . stripslashes($Row[9]) . "</td>";
echo "<td><strong>House Size:</strong><br />" . stripslashes($Row[10]) . " sq. ft.</td>";
echo "<td><strong>Lot Size:</strong><br />" . stripslashes($Row[11]) . " sq. ft.</td></tr>";
echo "<tr><td><strong>Notes:</strong><br />" . stripslashes($Row[12]) . "</td></tr>";
echo "<tr><td><strong>Link(s):</strong><br /><a href='" . stripslashes($Row[13]) . "'>" . stripslashes($Row[13]) . "</a><br /><a href='" . stripslashes($Row[14]) . "'>" . stripslashes($Row[14]) . "</a><br /><a href='" . stripslashes($Row[15]) . "'>" . stripslashes($Row[15]) . "</a></td></tr>";
echo "<tr><td><strong>Seen in person?</strong>  " . stripslashes($Row[16]) . "</td></tr>";
echo "<tr><td><strong>Additional Notes:</strong><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /></td></tr>";
echo "</table><br /><br /><br /><hr /><br /><br /><br />";
}

Link to comment
Share on other sites

Thank you for the great suggestion.  I hadn't even thought of colspan!  Doing it exactly like that didn't fix my table, but adjusting/customizing the colspan of each section helped me get a nice clean look.  It doesn't look exactly how I would like it to, but it's much better and certainly good enough to keep.  Thanks again.

 

Now, if I can just figure out how stop the multi-line Notes from messing up my page, I'll be set.  If anyone's interested, here's my updated script...

 

$HouseArray = file("houselist.txt");
$HouseArray = array_unique($HouseArray);
sort($HouseArray);

for ($i=0; $i<count($HouseArray); ++$i) {
$Row = explode("__", $HouseArray[$i]);
echo "<table width='60%' border='1'>";
echo "<tr><td colspan='4'><strong>Price:</strong> " . stripslashes($Row[0]) . "</td></tr>";
echo "<tr><td colspan='4'><img src='pics/" . stripslashes($Row[1]) . ".jpg'></td></tr>";
echo "<tr><td colspan='1'><strong>Park Name:</strong><br />" . stripslashes($Row[2]) . "</td>";
echo "<td colspan='2'><strong>Address:</strong><br />" . stripslashes($Row[3]) . "</td>";
echo "<td colspan='1'><strong>Phone #:</strong><br />" . stripslashes($Row[4]) . "</td></tr>";
echo "<tr><td colspan='1'><strong>Built:</strong> " . stripslashes($Row[5]) . "</td>";
echo "<td colspan='3'><strong>MLS #:</strong> " . stripslashes($Row[6]) . "</td></tr>";
echo "<tr><td colspan='4'><strong>Monthly Dues:</strong> " . stripslashes($Row[7]) . "</td></tr>";
echo "<tr><td colspan='1'><strong>Bedrooms:</strong><br />" . stripslashes($Row[8]) . "</td>";
echo "<td colspan='1'><strong>Bathrooms:</strong><br />" . stripslashes($Row[9]) . "</td>";
echo "<td colspan='1'><strong>House Size:</strong><br />" . stripslashes($Row[10]) . " sq. ft.</td>";
echo "<td colspan='1'><strong>Lot Size:</strong><br />" . stripslashes($Row[11]) . " sq. ft.</td></tr>";
echo "<tr><td colspan='4'><strong>Notes:</strong><br />" . stripslashes($Row[12]) . "</td></tr>";
echo "<tr><td colspan='4'><strong>Link(s):</strong><br /><a href='" . stripslashes($Row[13]) . "'>" . stripslashes($Row[13]) . "</a><br /><a href='" . stripslashes($Row[14]) . "'>" . stripslashes($Row[14]) . "</a><br /><a href='" . stripslashes($Row[15]) . "'>" . stripslashes($Row[15]) . "</a></td></tr>";
echo "<tr><td colspan='4'><strong>Seen in person?</strong>  " . stripslashes($Row[16]) . "</td></tr>";
echo "<tr><td colspan='4'><strong>Additional Notes:</strong><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /></td></tr>";
echo "</table><br /><br /><br /><hr /><br /><br /><br />";
}

Link to comment
Share on other sites

I doubt anyone cares, but I found the solution to my main issue. I thought the problem was with reading the array, but it was actually with writing it.

 

On the array-writing page, I had this variable:

 

$Notes = addslashes($_GET['notes']);

 

Underneath it, I added this:

 

$Notes = str_replace("\r\n", "<br />", $Notes);

 

And now it does exactly what I need. When a return is entered, str_replace converts it to a line break. This was giving me so much trouble because instead of doing this, I was trying to make my script read the \r\n returns and interpret them as line breaks. How silly of me.

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.