Page 1 of 1

Span Troubles

Posted: Tue Oct 22, 2013 7:30 pm
by Epiales
In my messages, I'm having trouble with it spanning out and going outside of borders. I have tried using max width and length and all types of stuff.

If I use a max width it jumbles the RE: into the date like this:

Image

If you look closely, you can see the subject RE: jumbling with the date.

If I don't use a max width, it goes beyond the table like this:

Image

So, not sure what to really do. Any ideas?

Also would be nice to get rid of all the special characters. Drives me mad lol

Re: Span Troubles

Posted: Tue Oct 22, 2013 10:12 pm
by Sharlenwar
Can we see this bit of code for where it loads the info from the database, and then displays it on the page?

Re: Span Troubles

Posted: Tue Oct 22, 2013 11:14 pm
by Epiales
Sharlenwar wrote:Can we see this bit of code for where it loads the info from the database, and then displays it on the page?
Code to read the messages with the reply button:

Code: Select all

if(isset($_POST['readmessage'])) {
$bypass = 1;
$randid = $_POST['randid'];
$date = $_POST['date'];


$updatemessage = "UPDATE messages SET readm='0' WHERE pid='$users_username' AND date='$date' AND randid='$randid'";
$user_query = mysqli_query($db_conx, $updatemessage);

$messageinfo = "SELECT * FROM messages where pid='$users_username' AND date='$date' AND randid='$randid'";
$user_query1 = mysqli_query($db_conx, $messageinfo);

$messageinfo3=mysqli_fetch_array($user_query1);

$messageinfo3['message'] =  nl2br(preg_replace('#(\\]{1})(\\s?)\\n#Usi', ']', stripslashes($messageinfo3['message'])));


echo "<b><font color='lime'>Subject: " . $messageinfo3['subject'] . "<br><br></b>From: " . $messageinfo3['sender'] . "      " . $messageinfo3['date'] . "<br><br>";    
echo " " . $messageinfo3['message'] . "<br><br><br>";

echo "<center><form method='post' action='messages.php?replyto=$messageinfo3[sender]&subcontent=$messageinfo3[subject]'><input type='submit' value='Reply'></center><input type='hidden' name='reply1' value='1'></form>";


echo "<br>";
echo "<center><form method='post' action='messages.php'><input type='submit' value='Delete'></center>
       <input type='hidden' name='deletemessage' value='1'>
       <input type='hidden' name='randid' value='$messageinfo3[randid]'>
       <input type='hidden' name='date' value='$messageinfo3[date]'>
       </form>";
       echo "<center><form method='post' action='messages.php'><input type='submit' value='Back to Inbox'>
       <input type='hidden' name='messages' value='1'>
          </form>";
 
This is the code that puts the input boxes for the user to be able to reply:

Code: Select all

if(isset($_POST['reply1'])) {
$bypass = 1;
if($bypass != 1)

{

}

$messageinfo = "SELECT * FROM messages where pid='$users_username' ";
$user_query1 = mysqli_query($db_conx, $messageinfo);
$messageinfo3=mysqli_fetch_array($user_query1);

echo "<div style='width:600px'>";
echo "<br><form method ='post' action = 'messages.php'>";
echo "Send To:   <input type = 'text' name = 'sendto' readonly size = '25' value= " . $_GET['replyto'] . ">";
echo "</div>";    

echo "<div>";
echo "Subject:     <input type = 'text' name = 'subject' width = '20px' size = '50' maxlength='20' value=Re:" .myUrlEncode($_GET['subcontent']). "><br><br>";
echo "</div>";

echo "<div style='vertical-align: top';>";    
echo "Content:    <textarea onfocus='limitTextarea(this,20)'  rows='15' cols='60' maxlength = '600' name = 'message'>";
echo "</textarea><br>";
echo "</div>";

echo "<input type = 'hidden' name = 'reply' value = '1'>";
echo "                <input type = 'submit' name = 'reply' id = 'reply' value = 'Reply'>";
echo "</form>";
}

 

This is the code that replies:

Code: Select all

if(isset($_POST['reply'])) {
echo "<br><br><br><span id='errormess'><big><center><font color='red'>Message Sent</center></span></big></font>"; ?>
<meta http-equiv="refresh" content="1;url=messages.php?messages=1">
<?php
$message =  protect($_POST["message"], ENT_QUOTES);
$subject = protect($_POST["subject"], ENT_QUOTES);
$sendto = protect($_POST["sendto"], ENT_QUOTES);
$randid = rand(999,9999999);

$sql = "INSERT INTO `messages` (`pid`,`sender`,`message`,`subject`,`randid`) VALUES ('".$sendto."','".$users_username."','".$message."','".$subject."','".$randid."')";
$user_query3 = mysqli_query($db_conx, $sql);

} 
This is the code that will display the messages:

Code: Select all

if(isset($_GET['messages']) || isset($_POST['messages']))
{
$bypass = 1;
echo "<small>";
echo "<left>";
echo "<table border = '0' width = '100%' cellspacing = '5'>";

echo "</td>";
echo "<td valign = 'top' width = '95%'>";

$messageinfo = "SELECT * FROM messages where pid='$users_username' ORDER BY date DESC";
$user_query = mysqli_query($db_conx, $messageinfo);
$numrows = mysqli_num_rows($user_query);

echo "<table>";

while ($row = mysqli_fetch_array($user_query, MYSQLI_ASSOC)) {

      if($row['readm'] == 1)
           {
         echo "<tr><td><left><font color = 'red'>  NEW!  </font></td>";
         }
         else
         {
         echo "<td><left></td>";
         }
             echo "<td><left>$row[sender]                </td><td><left>  $row[subject]                  </td><td><left>$row[date]             </td><td><left><form method='post' action='messages.php'><input type='submit' value='Read'>
       <input type='hidden' name='readmessage' value='1'>
       <input type='hidden' name='randid' value='$row[randid]'>
       <input type='hidden' name='date' value='$row[date]'>
        </form></td></tr>";
           
           }
      print "</table>";
      print "</td></tr></table>";    
               echo "</small>";    
}
 

Re: Span Troubles

Posted: Wed Oct 23, 2013 5:54 am
by MikuzA

Code: Select all

             echo "<td><left>$row[sender]                </td><td><left>  $row[subject]                  </td><td><left>$row[date]             </td><td><left>
Image

Re: Span Troubles

Posted: Wed Oct 23, 2013 5:16 pm
by Epiales
MikuzA wrote:

Code: Select all

             echo "<td><left>$row[sender]                </td><td><left>  $row[subject]                  </td><td><left>$row[date]             </td><td><left>

yah, I figured it would be somewhere in that code, but can't seem to find the right code to fix it :(

Re: Span Troubles

Posted: Wed Oct 23, 2013 5:24 pm
by MikuzA
Ok,

First of all, remove all of the  

Then look at how the page looks like.

Then use the tables to change it to way you want it.

Then implement to php.

However, if you wish to keep your   which you shouldn't, you could add a string length indicator on the subject to filter it.

As an example..

Code: Select all

if( strlen( $subject ) > 20 ) { $subject = left($subject, 20) . "..."; } 

Re: Span Troubles

Posted: Wed Oct 23, 2013 7:25 pm
by Epiales
I still spans out of the area:

Image

Like that picture...

I changed as you suggested:

Code: Select all

		 echo "<td><left>$row[sender]</td><td><left>$row[subject]</td><td><left>$row[date]</td><td><left><form method='post' action='messages.php'><input type='submit' value='Read'>
	   <input type='hidden' name='readmessage' value='1'>
	   <input type='hidden' name='randid' value='$row[randid]'>
	   <input type='hidden' name='date' value='$row[date]'>
	    </form></td></tr>";

Re: Span Troubles

Posted: Thu Oct 24, 2013 5:48 am
by Winawer
What are you trying to do? Cut off the text? Make it wrap? Stretch the table? The text will probably wrap automatically if you get rid of the underscores.

Also, <left> isn't a valid HTML tag.

Re: Span Troubles

Posted: Thu Oct 24, 2013 6:28 am
by MikuzA
Since you have no restriction on how long a subject can be,
I still suggest limiting it as I exampled before,

Code: Select all

if( strlen( $row[subject] ) > 20 ) { $row[subject] = left($row[subject], 20) . "..."; } 
 
Have that before you print out the $row[subject].

What that does is that it checks if $row[subject] string character length is more than 20, then it picks only the first 20 letters and adds '...' after it.
For example,

Code: Select all

$row['subject'] = "HelloIamlongsubjectwrittenwithoutspacesthatwilleasilydestroyyourpagejustbecauseItrytobeononelineandyoucantdomuchaboutit";
echo strlen($row['subject']); // This will result 119.

if( strlen( $row['subject'] ) > 20 ) { $row['subject'] = left($row['subject'], 20) . "..."; } 
echo $row['subject'] // This will result "HelloIamlongsubject..." 
Of course set the '20' to suit your needs. As a suggestion on optimizing the value use, use the a char that has the most width, for example MWMWMWMWMW. to see how many is the maximum. Then remove some of it to keep it on the safe side.

Also keep in mind that if your subject would have some spaces in it, it would most likely start creating extra lines for the subject, not sure if that's what you want, but limiting the subject like this fixes that issue also.

And for the   reaction, sorry for not being clear of my reasoning. :)
What I ment was that you can do the same formatting of centering by just using the tables. If you need more 'complex' coordination, add css to the table.

AND..

It seems that re :-colon is being transferred to %3A at some point, since the first Re: displays it correctly. Are you processing the Subject through $_GET?

Re: Span Troubles

Posted: Thu Oct 24, 2013 9:21 am
by Epiales
MikuzA wrote:Since you have no restriction on how long a subject can be,
I still suggest limiting it as I exampled before,

Code: Select all

if( strlen( $row[subject] ) > 20 ) { $row[subject] = left($row[subject], 20) . "..."; } 
Have that before you print out the $row[subject].

What that does is that it checks if $row[subject] string character length is more than 20, then it picks only the first 20 letters and adds '...' after it.
For example,

Code: Select all

$row['subject'] = "HelloIamlongsubjectwrittenwithoutspacesthatwilleasilydestroyyourpagejustbecauseItrytobeononelineandyoucantdomuchaboutit";
echo strlen($row['subject']); // This will result 119.

if( strlen( $row['subject'] ) > 20 ) { $row['subject'] = left($row['subject'], 20) . "..."; } 
echo $row['subject'] // This will result "HelloIamlongsubject..."  
Of course set the '20' to suit your needs. As a suggestion on optimizing the value use, use the a char that has the most width, for example MWMWMWMWMW. to see how many is the maximum. Then remove some of it to keep it on the safe side.

Also keep in mind that if your subject would have some spaces in it, it would most likely start creating extra lines for the subject, not sure if that's what you want, but limiting the subject like this fixes that issue also.

And for the   reaction, sorry for not being clear of my reasoning. :)
What I ment was that you can do the same formatting of centering by just using the tables. If you need more 'complex' coordination, add css to the table.

AND..

It seems that re :-colon is being transferred to %3A at some point, since the first Re: displays it correctly. Are you processing the Subject through $_GET?
Earlier I tried the strlen, but it said that I was calling an undefined function.... Will try again later. Heading out for a sleep :D... Thanks!