Shadowing Posted December 24, 2011 Share Posted December 24, 2011 So far with my inbox I got it to grab the message and display them in order by most recently sent. but now I want to add multiple inbox pages and set a limit on how many messages are on each page. I cant think of the idea behind of doing it. If someone could kindly guide me please. I know i need to use tokens in the link for each page but i dont understand the concept behind having newest messages to oldest showing up on each page <?php $take3 = "SELECT time_offset FROM users WHERE id='".mysql_real_escape_string($_SESSION['user_id'])."'"; $take2 = mysql_query($take3) or die(mysql_error()); $take1 = mysql_fetch_array($take2); $result = mysql_query("SELECT * FROM pm WHERE id = '".($_SESSION['user_id'])."' ORDER BY time DESC"); // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { $pm_id = $row['pm_id']; $msggoauld = $row['sentfrom']; $subject = $row['subject']; $recieved = $row['time']; $time = ($recieved + $take1['time_offset']); date_default_timezone_set('UTC'); $offset = date('m/d/Y/H:i:s', $time); ?> <tr> <td><center><input type="checkbox" name="messageid" class="select-all-box" value="327990" ?></center></td> </label></td> <td><center><a href="search_goaulds.php?goauld=<?php echo $msggoauld; ?>"><?php echo $msggoauld ?></a></center></td> <td><center><a href="view.php?pm_id=<?php echo $pm_id; ?>"><?php echo $subject ?></a></center></td> <td><center><?php echo $offset ?></center></td> </tr> <?php } // while loop ?> </table> <p> </p> </center> </p> </form> Quote Link to comment https://forums.phpfreaks.com/topic/253791-multi-page-inbox-help/ Share on other sites More sharing options...
Pikachu2000 Posted December 24, 2011 Share Posted December 24, 2011 It's called pagination: http://www.phpfreaks.com/tutorial/basic-pagination Quote Link to comment https://forums.phpfreaks.com/topic/253791-multi-page-inbox-help/#findComment-1301111 Share on other sites More sharing options...
Shadowing Posted December 24, 2011 Author Share Posted December 24, 2011 oh wow! thank you alot Pikachu. I had no idea it was called that I have one more question about keeping people from sending blank messages. Ive never had problems before with keeping blank forms from being submited. This is the first time using <textarea> for me. for some reason it ignores the code below and i even tried if (!isset($_POST['message_content'])) { <?php if(empty($_POST['message_content'])) { echo "cant send blank messages"; ?> <textarea rows="16" cols="65" name="message_content" id="message_content"> </textarea> Quote Link to comment https://forums.phpfreaks.com/topic/253791-multi-page-inbox-help/#findComment-1301112 Share on other sites More sharing options...
Pikachu2000 Posted December 24, 2011 Share Posted December 24, 2011 Without seeing the context of that code, it's impossible to say what's happening. Quote Link to comment https://forums.phpfreaks.com/topic/253791-multi-page-inbox-help/#findComment-1301114 Share on other sites More sharing options...
Shadowing Posted December 24, 2011 Author Share Posted December 24, 2011 oh so it shouldnt be happening then. hmm i did notice something else wierd too when im on the subject input and hit tab to tab down into the textarea it skips the first line in the text area <?php if(isset($_POST['send'])) { $send3 = "SELECT goauld,id FROM users WHERE goauld='".mysql_real_escape_string($_POST['message_to'])."'"; $send2 = mysql_query($send3) or die(mysql_error()); $send1 = mysql_fetch_array($send2); $from3 = "SELECT goauld FROM users WHERE id='".mysql_real_escape_string($_SESSION['user_id'])."'"; $from2 = mysql_query($from3) or die(mysql_error()); $from1 = mysql_fetch_array($from2); $goauld_name = $_POST['message_to']; $phptime = time(); $to = $_POST['message_to']; $from = $from1['goauld']; $subject = $_POST['subject']; $id = $send1['id']; $message = $_POST['message_content']; if(empty($send1['goauld'])) { echo "This Goauld doesnt exist"; }else{ if(empty($_POST['message_content'])) { echo "You cant send a blank message"; }else{ $mail2 = "INSERT INTO pm SET pm_id = '', sendto = '".mysql_real_escape_string($to)."', sentfrom = '".mysql_real_escape_string($from)."' , subject = '".mysql_real_escape_string($subject)."' , id= '".mysql_real_escape_string($id)."', message= '".mysql_real_escape_string($message)."', time= '".mysql_real_escape_string($phptime)."'"; $mail1 = mysql_query($mail2); echo "Your message has been sent to $goauld_name"; } } } ?> <table width="28%" height="0" border="0"> <tr> <td height="0" align="center"><a href="inbox.php">Inbox</a> </td> <td height="0" align="center"><a href="compose.php">Compose</a></td> <td height="0" align="center"><a href="sent.php">Sent</a></td> <td height="0" align="center"><a href="trash.php">Trash</a></td> </tr> <tr> </tbody> </table> </form> <form name="message" action="" method="post"> <input type="text" name="message_to" id="message_to" onfocus="if(this.value=='Name')this.value='';" value="<?php echo htmlspecialchars($_GET['goauld']);?>"> To: <br> <input type="text" name="subject" id="subject" > Subject: <br> Message: <br> <textarea rows="16" cols="65" name="message_content" id="message_content"> </textarea> <input type="submit" name="send" id="send" value="Send"> </tbody> </table> </form> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/253791-multi-page-inbox-help/#findComment-1301115 Share on other sites More sharing options...
Pikachu2000 Posted December 24, 2011 Share Posted December 24, 2011 If there's so much as a single space in a field, it will be !empty. You should be trimming the incoming data before validating that the field is !empty. Quote Link to comment https://forums.phpfreaks.com/topic/253791-multi-page-inbox-help/#findComment-1301173 Share on other sites More sharing options...
Shadowing Posted December 25, 2011 Author Share Posted December 25, 2011 Hey Pikachu your "Why $_SERVER['PHP_SELF'] is bad" link isnt working must not exist anymore. I notice the tutor you linked me for Pagination uses $_SERVER['PHP_SELF'] either way thank you so much to pointing me that link I got it all working. I have a few small bugs in the links though that i need to sort out. will try to fix it on my own first what did you mean by trimming the incoming data? never heard that term before Quote Link to comment https://forums.phpfreaks.com/topic/253791-multi-page-inbox-help/#findComment-1301232 Share on other sites More sharing options...
melloorr Posted December 25, 2011 Share Posted December 25, 2011 It means getting rid of excess spaces. I.E. $hello = " Hello!"; trim($hello) Would get out the spaces at the beginning. So it will effectivly be $hello = "Hello!"; Quote Link to comment https://forums.phpfreaks.com/topic/253791-multi-page-inbox-help/#findComment-1301233 Share on other sites More sharing options...
Pikachu2000 Posted December 25, 2011 Share Posted December 25, 2011 Hey Pikachu your "Why $_SERVER['PHP_SELF'] is bad" link isnt working must not exist anymore. I don't see how it could not work, it's a link to a Google search result. Quote Link to comment https://forums.phpfreaks.com/topic/253791-multi-page-inbox-help/#findComment-1301235 Share on other sites More sharing options...
Shadowing Posted December 25, 2011 Author Share Posted December 25, 2011 oh my bad i thought you meant it to go to a site other then a google search result lol. and I thought maybe the site didnt exist so google forward it into a search result or something. anyways you was right what was wrong with the space issue and me not being able check for a empty field. All fixed and thanks for explaining that to me melloorr I'll mark this as solved, im going to start using the solve feature on the forum. going to even go back and do it on past posts ive posted. incase someone else has this issue with textarea with html i solved it by not having any spaces between id="message_content"> and </textarea> <textarea rows="16" cols="65" name="message_content" id="message_content"></textarea> Quote Link to comment https://forums.phpfreaks.com/topic/253791-multi-page-inbox-help/#findComment-1301238 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.