Jump to content

help with arrays


droopz17

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.