YAY Lining Things Up!!! [RESOLVED]

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.

YAY Lining Things Up!!! [RESOLVED]

Postby Epiales » Wed Oct 01, 2014 6:07 pm

I finally have the messaging system done. It sends the messages, displays, and deletes the messages. It alerts player if it's a new message, and it's paginated. But it looks like total garbage b/c nothing is lined up :lol: :lol: :lol:

I've tried using <td></td> and spaces and everything to get it lined up, but all it dies is mess up the outlay of the while loop display. Any help would be greatly appreciated.

Code: Select all
<?php
$bypass 
= 0;
if(
$bypass != 1)

{
if(isset(
$_GET['messages']) || isset($_POST['messages'])) 
{
$bypass = 1;

$sql = "SELECT * FROM messages WHERE pid='$user_username' ORDER BY date DESC"; 
$user_query 
= mysqli_query($db_conx, $sql);
$nr = mysqli_num_rows($user_query);

echo "<left>";
echo "<table border = '0' width = '100%' cellspacing = '5'>";


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

if (isset($_GET['pn'])) {  
    $pn 
= preg_replace('#[^0-9]#i', '', $_GET['pn']);  

} else { 
    $pn 
= 1;
}
 

$itemsPerPage 
= 5; 

$lastPage 
= ceil($nr / $itemsPerPage);

if ($pn < 1) {  
    $pn 
= 1;  
} else if ($pn > $lastPage) {  
    $pn 
= $lastPage;  
} 

$centerPages 
= "";
$sub1 = $pn - 1;
$sub2 = $pn - 2;
$add1 = $pn + 1;
$add2 = $pn + 2;
if ($pn == 1) {
    $centerPages .= '&nbsp; <span class="pagNumActive">' . $pn . '</span> &nbsp;';
    $centerPages .= '&nbsp; <a href="' . $_SERVER['PHP_SELF'] . '?messages=1&pn=' . $add1 . '">' . $add1 . '</a> &nbsp;';
}
 else if ($pn == $lastPage) {
    $centerPages .= '&nbsp; <a href="' . $_SERVER['PHP_SELF'] . '?messages=1&pn=' . $sub1 . '">' . $sub1 . '</a> &nbsp;';
    $centerPages .= '&nbsp; <span class="pagNumActive">' . $pn . '</span> &nbsp;';
}
 else if ($pn > 2 && $pn < ($lastPage - 1)) {
    $centerPages .= '&nbsp; <a href="' . $_SERVER['PHP_SELF'] . '?messages=1&pn=' . $sub2 . '">' . $sub2 . '</a> &nbsp;';
    $centerPages .= '&nbsp; <a href="' . $_SERVER['PHP_SELF'] . '?messages=1&pn=' . $sub1 . '">' . $sub1 . '</a> &nbsp;';
    $centerPages .= '&nbsp; <span class="pagNumActive">' . $pn . '</span> &nbsp;';
    $centerPages .= '&nbsp; <a href="' . $_SERVER['PHP_SELF'] . '?messages=1&pn=' . $add1 . '">' . $add1 . '</a> &nbsp;';
    $centerPages .= '&nbsp; <a href="' . $_SERVER['PHP_SELF'] . '?messages=1&pn=' . $add2 . '">' . $add2 . '</a> &nbsp;';
}
 else if ($pn > 1 && $pn < $lastPage) {
    $centerPages .= '&nbsp; <a href="' . $_SERVER['PHP_SELF'] . '?messages=1&pn=' . $sub1 . '">' . $sub1 . '</a> &nbsp;';
    $centerPages .= '&nbsp; <span class="pagNumActive">' . $pn . '</span> &nbsp;';
    $centerPages .= '&nbsp; <a href="' . $_SERVER['PHP_SELF'] . '?messages=1&pn=' . $add1 . '">' . $add1 . '</a> &nbsp;';
}

$limit = 'LIMIT ' .($pn - 1) * $itemsPerPage .',' .$itemsPerPage; 

$sql 
= "SELECT * FROM messages WHERE pid='$user_username' ORDER BY date DESC, readm=1 DESC $limit"; 
$user_query 
= mysqli_query($db_conx, $sql);
$numrows = mysqli_num_rows($user_query);

$paginationDisplay = "";  

if 
($lastPage != "1"){

    $paginationDisplay .= 'Page <strong>' . $pn . '</strong> of ' . $lastPage. '&nbsp;  &nbsp;  &nbsp; ';

    if ($pn != 1) {
        $previous = $pn - 1;
        $paginationDisplay .=  '&nbsp;  <a href="' . $_SERVER['PHP_SELF'] . '?messages=1&pn=' . $previous . '"> Back</a> ';
    } 

    $paginationDisplay 
.= '<span class="paginationNumbers">' . $centerPages . '</span>';

    if ($pn != $lastPage) {
        $nextPage = $pn + 1;
        $paginationDisplay .=  '&nbsp;  <a href="' . $_SERVER['PHP_SELF'] . '?messages=1&pn=' . $nextPage . '"> Next</a> ';
    } 
}

$outputList = '';

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

    $row['subject'] = left($row['subject'], 20) . "...";     
    if
($row['readm'] == 1) {

    $outputList .= "<left><font color = 'red'>NEW!&nbsp;&nbsp;&nbsp;</font><left>$row[sender]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<left>$row[subject]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<left>$row[date]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<right><form method='post' action='mafiawarskingdom.php?messages=1'><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>"
;
         
}
         else
         
{
    $outputList .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <left></font><left>$row[sender]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<left>$row[subject]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<left>$row[date]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<right><form method='post' action='mafiawarskingdom.php?messages=1'><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>"
;

        }     
        
    
}
}

?>


Code that displays output below. Now if I remove what tables I have echoed, it will completely mess up the form and throw everything on different rows or such. So instead of changing the format I have, I need to just be able to add to it in order to line everything up IF I can. Thank you again, and sorry for all the posts. Here is what it currently looks like:

Image

Code: Select all

   </div> 
      <div style="padding:6px; background-color:#FFF; border:#999 1px solid;"><?php echo $paginationDisplay; ?></div>
      <div align="left"><?php echo "$outputList"; ?></div>
      <div style="padding:6px; background-color:#FFF; border:#999 1px solid;"><?php echo $paginationDisplay; ?></div>

<?php

}           
      echo 
"</table>";
      echo "</td></tr></table>";    
      echo 
"</small>";    
?>
Last edited by Epiales on Thu Oct 02, 2014 4:17 pm, edited 1 time in total.
Nothing fancy, but a work in progress!

http://gameplaytoday.net
User avatar
Epiales
 
Posts: 1119
Joined: Wed Aug 14, 2013 8:38 pm
Has thanked: 62 times
Been thanked: 6 times

Re: YAY Lining Things Up!!!

Postby Sim » Wed Oct 01, 2014 9:33 pm

Im not much of an HTML expert BUT

Code: Select all
"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <left></font><left>$row[sender]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<left>$row[subject]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<left>$row[date]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;


BADDDDDDDDDDDDDDDDDDDDDDD.. I would just use some tables and a center tag?
oRPG Creator - Make Your Own Browser Game
oRPG Creator on Facebook
Sim
 
Posts: 412
Joined: Sat Dec 26, 2009 12:37 pm
Location: Baltimore
Has thanked: 39 times
Been thanked: 13 times
Blog: View Blog (1)

Re: YAY Lining Things Up!!!

Postby MikuzA » Thu Oct 02, 2014 4:24 am

Yes, that &nbsp; repeating is kinda awful :D
When developing, just put them in a table for starters, and then when you feel fancy and your code is ready.. Start digging into Div's if necessary. But table combined with css is a best approach when doing similiar row loop when outputting data.

Code: Select all
<form method='post' action='mafiawarskingdom.php?messages=1'> // this outside of the table or inside the table right after <table>, but out of the loop.
<table> //put this outside the 'loop'

<tr> //starting a new row

<td width=100>  //just some width for the first column to have the 'NEW' in sync if there's not 'NEW'-flash.
<font color="RED">NEW!</font> // remove this from the other condition, ofc.
</td> // ending first column.

<td> // starting sender column.
$row['sender'] // inserting sender_data
</td> // ending column..

<td> // starting subject column.
$row['subject'] // inserting subject_data
</td> // ending column..

<td> //starting received date-column
$row['date'] //inserting date-data
</td> //ending column

<td> // starting 'READ'-button column
<input type='submit' name='Read' value='$mail_id'> // perhaps change this to something like this, so you don't have to recreate your form for every e-mail. And move the <form> before or after the <table>-outside the loop.
</td> // ending the column

</tr> // ending the row

//while-loop ends here.

</table> // end the table.



Hope this helps, this is really a 'hand-held' guidance through, so pick the stuff you need :) (have not tested, there might be typos)
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
MikuzA
 
Posts: 395
Joined: Thu Aug 08, 2013 3:57 am
Location: Helsinki, Finland
Has thanked: 0 time
Been thanked: 21 times

Re: YAY Lining Things Up!!!

Postby Epiales » Thu Oct 02, 2014 6:10 am

Sim wrote:Im not much of an HTML expert BUT

Code: Select all
"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <left></font><left>$row[sender]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<left>$row[subject]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<left>$row[date]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;


BADDDDDDDDDDDDDDDDDDDDDDD.. I would just use some tables and a center tag?


LMAO! I know I know I know :mrgreen: :mrgreen: :mrgreen: :oops: :oops: :oops:

But I have tried doing it with tables and it just messes it all up worse lol. But yeah, I agree, they are really bad.
Nothing fancy, but a work in progress!

http://gameplaytoday.net
User avatar
Epiales
 
Posts: 1119
Joined: Wed Aug 14, 2013 8:38 pm
Has thanked: 62 times
Been thanked: 6 times

Re: YAY Lining Things Up!!!

Postby Epiales » Thu Oct 02, 2014 6:11 am

MikuzA wrote:Yes, that &nbsp; repeating is kinda awful :D
When developing, just put them in a table for starters, and then when you feel fancy and your code is ready.. Start digging into Div's if necessary. But table combined with css is a best approach when doing similiar row loop when outputting data.

Code: Select all
<form method='post' action='mafiawarskingdom.php?messages=1'> // this outside of the table or inside the table right after <table>, but out of the loop.
<table> //put this outside the 'loop'

<tr> //starting a new row

<td width=100>  //just some width for the first column to have the 'NEW' in sync if there's not 'NEW'-flash.
<font color="RED">NEW!</font> // remove this from the other condition, ofc.
</td> // ending first column.

<td> // starting sender column.
$row['sender'] // inserting sender_data
</td> // ending column..

<td> // starting subject column.
$row['subject'] // inserting subject_data
</td> // ending column..

<td> //starting received date-column
$row['date'] //inserting date-data
</td> //ending column

<td> // starting 'READ'-button column
<input type='submit' name='Read' value='$mail_id'> // perhaps change this to something like this, so you don't have to recreate your form for every e-mail. And move the <form> before or after the <table>-outside the loop.
</td> // ending the column

</tr> // ending the row

//while-loop ends here.

</table> // end the table.



Hope this helps, this is really a 'hand-held' guidance through, so pick the stuff you need :) (have not tested, there might be typos)


Thank m8! I will try again lol. If at first you don't succeed, try, try again. I will update trying to use u're formula. Thank you!
Nothing fancy, but a work in progress!

http://gameplaytoday.net
User avatar
Epiales
 
Posts: 1119
Joined: Wed Aug 14, 2013 8:38 pm
Has thanked: 62 times
Been thanked: 6 times

Re: YAY Lining Things Up!!!

Postby Epiales » Thu Oct 02, 2014 7:11 am

Thanks everyone! I think I have it finished now

Image
Nothing fancy, but a work in progress!

http://gameplaytoday.net
User avatar
Epiales
 
Posts: 1119
Joined: Wed Aug 14, 2013 8:38 pm
Has thanked: 62 times
Been thanked: 6 times


Return to Beginner Help and Support

Who is online

Users browsing this forum: No registered users and 1 guest

cron

x