Span Troubles

Place for questions and answers for all newcomers and new coders. This is a free for all forum, no question is too stupid and to noob.
Post Reply
User avatar
Epiales
Posts: 1119
Joined: Thu Aug 15, 2013 1:38 am

Span Troubles

Post 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
Nothing fancy, but a work in progress!

http://gameplaytoday.net
User avatar
Sharlenwar
Posts: 523
Joined: Mon May 28, 2012 7:14 pm

Re: Span Troubles

Post 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?
Deep within the Void of Quasion, a creation.

**My Corner of the Web**
***NEW***GrindFest - My own PHP/MySQL game!
Sharlenwar's Adventures
Torn-City - Massively multiplayer online text based RPG
User avatar
Epiales
Posts: 1119
Joined: Thu Aug 15, 2013 1:38 am

Re: Span Troubles

Post 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>";    
}
 
Nothing fancy, but a work in progress!

http://gameplaytoday.net
User avatar
MikuzA
Posts: 394
Joined: Thu Aug 08, 2013 8:57 am

Re: Span Troubles

Post by MikuzA »

Code: Select all

             echo "<td><left>$row[sender]                </td><td><left>  $row[subject]                  </td><td><left>$row[date]             </td><td><left>
Image
Why so serious?

Business Intelligence, Data Engineering, Data Mining
PHP, HTML, JavaScript, Bash/KornShell, Python, C#, PL/SQL
MySQL, DB2, Oracle, Snowflake
Pentaho, DataStage, Matillion, Unity3D, Blender
User avatar
Epiales
Posts: 1119
Joined: Thu Aug 15, 2013 1:38 am

Re: Span Troubles

Post 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 :(
Nothing fancy, but a work in progress!

http://gameplaytoday.net
User avatar
MikuzA
Posts: 394
Joined: Thu Aug 08, 2013 8:57 am

Re: Span Troubles

Post 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) . "..."; } 
Why so serious?

Business Intelligence, Data Engineering, Data Mining
PHP, HTML, JavaScript, Bash/KornShell, Python, C#, PL/SQL
MySQL, DB2, Oracle, Snowflake
Pentaho, DataStage, Matillion, Unity3D, Blender
User avatar
Epiales
Posts: 1119
Joined: Thu Aug 15, 2013 1:38 am

Re: Span Troubles

Post 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>";
Nothing fancy, but a work in progress!

http://gameplaytoday.net
Winawer
Posts: 180
Joined: Wed Aug 17, 2011 5:53 am

Re: Span Troubles

Post 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.
User avatar
MikuzA
Posts: 394
Joined: Thu Aug 08, 2013 8:57 am

Re: Span Troubles

Post 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?
Why so serious?

Business Intelligence, Data Engineering, Data Mining
PHP, HTML, JavaScript, Bash/KornShell, Python, C#, PL/SQL
MySQL, DB2, Oracle, Snowflake
Pentaho, DataStage, Matillion, Unity3D, Blender
User avatar
Epiales
Posts: 1119
Joined: Thu Aug 15, 2013 1:38 am

Re: Span Troubles

Post 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!
Nothing fancy, but a work in progress!

http://gameplaytoday.net
Post Reply

Return to “Beginner Help and Support”