droopz17 Posted June 26, 2007 Share Posted June 26, 2007 I have created an inbox style kinda like yahoo. where when you click on the subject it goes to the message. It knows which message to goto cuz i have it call to the message_id, but my problem is how would i make it so when you in the main message that it would goto the next message or the last message. exp. subject: testing email Message: test message test message test message test message test message test message test message test message test message test message test message test message test message test message test message test message test message test message test message test message test message test message test message test message test message test message test message test message test message test message test message test message test message test message test message test message test message test message test message test message test message test message test message test message test message test message test message test message last next I thought about running the same query and then using like an while statement along with the message_id, and current(),next(),last() kinda like $i = current($array); while( $i !== $message_id ){ next($array); } or something along that route. But I'm kinda new a php which i'm sure you can already tell but i've figured alot of stuff out just by trial and error but some help would be great. Link to comment https://forums.phpfreaks.com/topic/57293-help-with-arrays/ Share on other sites More sharing options...
per1os Posted June 26, 2007 Share Posted June 26, 2007 Current and next are really unnecessary. www.php.net/foreach <?php $message = ""; $array = array("Message1", "Message2"); foreach ($array as $key => $val) { $message .= $val . "\n"; } echo $message; ?> Link to comment https://forums.phpfreaks.com/topic/57293-help-with-arrays/#findComment-283191 Share on other sites More sharing options...
droopz17 Posted June 26, 2007 Author Share Posted June 26, 2007 not exactly what i'm looking for, i'll have to post my actual code on here tonight when i get home. I'm basically going from one page that displays rows of message by who sent it and the subject, like the yahoo inbox. and then having it link to another page that shows the message like as if you were in yahoo and clicked on the subject and it takes you to your message. well i got that working but i'm not really sure how to make the next, and last message links work being that i am displaying the message with the message id. Link to comment https://forums.phpfreaks.com/topic/57293-help-with-arrays/#findComment-283316 Share on other sites More sharing options...
corillo181 Posted June 26, 2007 Share Posted June 26, 2007 is simple start where the current message is at and say the magic words to mysql [code]<?php $getPrevious=mysql_query("select from messages where user_id=$id and message<$currentmess"); ?> to get the next message is the same basic script[/code] Link to comment https://forums.phpfreaks.com/topic/57293-help-with-arrays/#findComment-283323 Share on other sites More sharing options...
droopz17 Posted June 26, 2007 Author Share Posted June 26, 2007 K that's kinda what i was thinking but one thing i'm not sure how to do it when i'm sorting it. so that way i keep sorted the same, i thought of carrying those over with your script like so. link would be kinda like http://www.whatever.com/my_messages.php?acc=desc&col=date <?php $acc = $_REQUEST['acc']; $col = $_REQUEST['col']; $getPrevious=mysql_query("select from messages where user_id=$id and message<$currentmess by $col $acc"); ?> now when you put message<$currentmess will that display one back or how is that actually gonna work. Do I have the right idea? Link to comment https://forums.phpfreaks.com/topic/57293-help-with-arrays/#findComment-283391 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.